def run(self): while not self.terminated: try: tcb, callable_, args, kwargs = self.events_to_process.get(True, 10) except queue.Empty: continue if tcb.is_alive: S.loc.tcb = tcb callable_(*args, **kwargs) tcb.pending -= 1 if tcb.shouldBeCollected(): tcb.is_alive = False S.onTaskletTerminated(tcb)
def run(self): while not self.terminated: try: tcb, callable_, args, kwargs = self.events_to_process.get( True, 10) except queue.Empty: continue if tcb.is_alive: S.loc.tcb = tcb callable_(*args, **kwargs) tcb.pending -= 1 if tcb.shouldBeCollected(): tcb.is_alive = False S.onTaskletTerminated(tcb)
def terminate(self, result1=None): if self.user == 'SYSTEMYA': if result1 != None: S.schedule(S.loc.tcb, result1, Tasklet.AccessDenied) try: tcb = S.tcbs[self.tid] if not tcb.is_alive: raise KeyError except KeyError: if result1 != None: S.schedule(S.loc.tcb, result1, Tasklet.DoesNotExist) else: # OK, we got the tasklet, kill'em if result1 != None: if S.loc.tcb != tcb: S.schedule(S.loc.tcb, result1, True) S.onTaskletTerminated(tcb)