Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
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)
Ejemplo n.º 3
0
 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)