MCPcopy Index your code
hub / github.com/python/cpython / _handle_workers

Method _handle_workers

Lib/multiprocessing/pool.py:507–525  ·  view source on GitHub ↗
(cls, cache, taskqueue, ctx, Process, processes,
                        pool, inqueue, outqueue, initializer, initargs,
                        maxtasksperchild, wrap_exception, sentinels,
                        change_notifier)

Source from the content-addressed store, hash-verified

505
506 @classmethod
507 def _handle_workers(cls, cache, taskqueue, ctx, Process, processes,
508 pool, inqueue, outqueue, initializer, initargs,
509 maxtasksperchild, wrap_exception, sentinels,
510 change_notifier):
511 thread = threading.current_thread()
512
513 # Keep maintaining workers until the cache gets drained, unless the pool
514 # is terminated.
515 while thread._state == RUN or (cache and thread._state != TERMINATE):
516 cls._maintain_pool(ctx, Process, processes, pool, inqueue,
517 outqueue, initializer, initargs,
518 maxtasksperchild, wrap_exception)
519
520 current_sentinels = [*cls._get_worker_sentinels(pool), *sentinels]
521
522 cls._wait_for_updates(current_sentinels, change_notifier)
523 # send sentinel to stop workers
524 taskqueue.put(None)
525 util.debug('worker handler exiting')
526
527 @staticmethod
528 def _handle_tasks(taskqueue, put, outqueue, pool, cache):

Callers

nothing calls this directly

Calls 5

_maintain_poolMethod · 0.80
_get_worker_sentinelsMethod · 0.45
_wait_for_updatesMethod · 0.45
putMethod · 0.45
debugMethod · 0.45

Tested by

no test coverage detected