def post(self, strategy, quantum=4, ts=10): #import pdb; pdb.set_trace() # parse process syntax args = self.parser.parse_args() processDescription = args.get("syntax") init_p = args.get("initial_process") # trying to parse the syntax parseSyntax(processDescription) # here comes the critical section: creating the Scheduler environmet including Singletons. try: # generate scheduler scheduler = SchedulerFactory.getScheduler(str(strategy), quantum=quantum, timeslice=ts) # run scheduler scheduler.initialize(init_p) scheduler.run() # generate JSON json_result = JsonSerializer().generateData() except Exception as e: # pass the exceptions to the api - it will translate it to json-requests raise e finally: # we make sure that even after an exception, all Singletons get destroyed. ProcessManager._drop() SystemTimer._drop() return json_result, 200
def tearDown(self): ProcessManager._drop() SystemTimer._drop()
def tearDown(self): # cleanup process manager instances ProcessManager._drop() SystemTimer._drop()
def tearDown(self): #clean all processes ProcessManager._drop() SystemTimer._drop()
def tearDown(self): SystemTimer._drop() ProcessManager._drop()
def tearDown(self): # because the timer class is implemented as Singleton, we have weird side effects # while unittesting. So we need un-register every listener after a run. self.stimer.unregisterAll() # ...hmm.. just to make sure, drop the SystemTimer instance SystemTimer._drop()