Пример #1
0
def interpreter_shutdown():
    global global_shutdown
    global_shutdown = True

    workers = [
        p for p in multiprocessing.active_children() if p.name == WORKERS_NAME
    ]

    for worker in workers:
        stop_process(worker)
Пример #2
0
 def stop_worker(self, worker_id, force=False):
     try:
         if force:
             stop_process(self.workers.pop(worker_id))
         else:
             with self.workers_channel.lock:
                 stop_process(self.workers.pop(worker_id))
     except ChannelError as error:
         raise BrokenProcessPool(error)
     except KeyError:
         return  # worker already expired
Пример #3
0
 def stop_worker(self, worker_id, force=False):
     try:
         if force:
             stop_process(self.workers.pop(worker_id))
         else:
             with self.workers_channel.lock:
                 stop_process(self.workers.pop(worker_id))
     except ChannelError as error:
         raise BrokenProcessPool(error)
     except KeyError:
         return  # worker already expired
Пример #4
0
def _worker_handler(future, worker, pipe, timeout):
    """Worker lifecycle manager.

    Waits for the worker to be perform its task,
    collects result, runs the callback and cleans up the process.

    """
    result = _get_result(future, pipe, timeout)

    if isinstance(result, BaseException):
        if isinstance(result, ProcessExpired):
            result.exitcode = worker.exitcode

        future.set_exception(result)
    else:
        future.set_result(result)

    if worker.is_alive():
        stop_process(worker)
Пример #5
0
def _worker_handler(future, worker, pipe, timeout):
    """Worker lifecycle manager.

    Waits for the worker to be perform its task,
    collects result, runs the callback and cleans up the process.

    """
    result = _get_result(future, pipe, timeout)

    if isinstance(result, BaseException):
        if isinstance(result, ProcessExpired):
            result.exitcode = worker.exitcode

        future.set_exception(result)
    else:
        future.set_result(result)

    if worker.is_alive():
        stop_process(worker)