def stop_worker(self, worker_id): try: with self.workers_channel.lock: stop(self.workers.pop(worker_id)) except KeyError: return # worker already expired except ChannelError as error: raise PoolError(error)
def task_manager(task, pipe): """Task's lifecycle manager. Waits for the *Task* to be performed, collects results, runs the callback and cleans up the process. """ worker = task._worker results = get_results(pipe, task.timeout) if isinstance(results, ProcessExpired): results.exitcode = worker.exitcode task.set_results(results) if worker.is_alive(): stop(worker)
def cancel(self): """Overrides the *Task* cancel method in order to signal it to the *process* decorator handler.""" super(ProcessTask, self).cancel() stop(self._worker)