def _send_task(self, code): """ Overridden function, the task is added to the ventilator global_wait_task attribute, emulating the ventilator task registration. """ if self.worker.display: print('Send: ' + str([code, self.procedure, self.needed])) task_depend = set([decode_output(str(n)) for n in self.needed]) task = WaitingTask(code, self.needed, self.procedure, self.worker) self_needed = code in task_depend if self_needed: task_depend.remove(code) task.set_left(task_depend, self_needed) if task_depend: for n in task_depend: list_task = self.worker.global_wait_task.setdefault(n, []) list_task.append(task) else: task.update_data(0)
def db_delete_needed(self): """Delete from the database the intern data of the database, i.e., codes in self.needed with task equal to the code attribute.""" code_list = filter(lambda(x): decode_output(x) == self.code, self.needed) with self.ventilator.redis.pipeline() as pipe: while True: try: pipe.watch(code_list) pipe.multi() [pipe.delete(code) for code in code_list] res = pipe.execute() if self.ventilator.display: print('Redis delete: ; ' + str(code_list)) print(' ' + str(res)) return res except WatchError: continue finally: pipe.reset()
def db_delete_needed(self): """Delete from the database the intern data of the database, i.e., codes in self.needed with task equal to the code attribute.""" code_list = filter(lambda (x): decode_output(x) == self.code, self.needed) with self.ventilator.redis.pipeline() as pipe: while True: try: pipe.watch(code_list) pipe.multi() [pipe.delete(code) for code in code_list] res = pipe.execute() if self.ventilator.display: print('Redis delete: ; ' + str(code_list)) print(' ' + str(res)) return res except WatchError: continue finally: pipe.reset()