self.steps = steps else: self.steps = [] self.progress = 0 self.scheduler = scheduler def addWork(self, callable, *args, **kw): self.steps.append([callable, args, kw]) def __call__(self): if self.progress < len(self.steps): func, args, kw = self.steps[self.progress] try: apply(func, args, kw) except: log.msg( 'Exception in Task' ) traceback.print_exc(file=log.logfile) return 0 else: self.progress = self.progress + 1 # if we still have tasks left we add ourselves to the scheduler if self.progress < len(self.steps): self.scheduler.addTask(self) return 1 return 0 # Sibling Imports import main main.addDelayed(theScheduler)
def wakeAddDelayed(delayed): addDelayed(delayed) main.waker.wakeUp()