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

Method _adjust_process_count

Lib/concurrent/futures/process.py:771–789  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

769 self._executor_manager_thread_wakeup
770
771 def _adjust_process_count(self):
772 # gh-132969: avoid error when state is reset and executor is still running,
773 # which will happen when shutdown(wait=False) is called.
774 if self._processes is None:
775 return
776
777 # if there's an idle process, we don't need to spawn a new one.
778 if self._idle_worker_semaphore.acquire(blocking=False):
779 return
780
781 process_count = len(self._processes)
782 if process_count < self._max_workers:
783 # Assertion disabled as this codepath is also used to replace a
784 # worker that unexpectedly dies, even when using the 'fork' start
785 # method. That means there is still a potential deadlock bug. If a
786 # 'fork' mp_context worker dies, we'll be forking a new one when
787 # we know a thread is running (self._executor_manager_thread).
788 #assert self._safe_to_dynamically_spawn_children or not self._executor_manager_thread, 'https://github.com/python/cpython/issues/90622'
789 self._spawn_process()
790
791 def _launch_processes(self):
792 # https://github.com/python/cpython/issues/90622

Callers 2

submitMethod · 0.95
runMethod · 0.80

Calls 2

_spawn_processMethod · 0.95
acquireMethod · 0.45

Tested by

no test coverage detected