"""
def handledata(data,module): #unpack task task=Task() task.unpack(data) def handleok(data,module,task): #find thread thread=None for t in self.threads: if t[0]["task"].threadid==task.threadid: thread=t break #check thread if thread is None: return #log error (thread not found!) #find task index=None for i in range(len(thread)): if thread[i]["task"].id==task.id: index=i break #check task if index is None: return #log error (task not found!) #update task thread[index]["task"]=task thread[index]["module"]=None #is there a next task in the thread? if index==len(thread)-1: #delete thread, we're done self.threads.remove(thread) #append thread to history self.history.append(thread) if len(self.history)>10: self.history=self.history[-10:] else: #assign result to next task in thread thread[index]["task"].load() thread[index+1]["task"].data=thread[index]["task"].result thread[index+1]["task"].save() #free the memory we just used up thread[index]["task"].unload() thread[index+1]["task"].unload() #mark next task on thread as scheduled thread[index+1]["task"].status=Task.STATUS_SCHEDULED #done module.lock=False module.tasks=module.tasks[1:] def handleerr(err,module): #flush call failed. will try again in next monitor cycle module.lock=False deferred=module.call("flush") deferred.addCallback(handleok,module=module,task=task) deferred.addErrback(handleerr,module=module)