gh-90622: Prevent max_tasks_per_child use with a fork mp_context. (#91587)

Prevent `max_tasks_per_child` use with a "fork" mp_context to avoid deadlocks.

Also defaults to "spawn" when no mp_context is supplied for safe convenience.
This commit is contained in:
Gregory P. Smith 2022-05-06 00:04:53 -07:00 committed by GitHub
parent 2b563f1ad3
commit fa4f0a134e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 11 deletions

View file

@ -254,8 +254,11 @@ to a :class:`ProcessPoolExecutor` will result in deadlock.
*max_tasks_per_child* is an optional argument that specifies the maximum
number of tasks a single process can execute before it will exit and be
replaced with a fresh worker process. The default *max_tasks_per_child* is
``None`` which means worker processes will live as long as the pool.
replaced with a fresh worker process. By default *max_tasks_per_child* is
``None`` which means worker processes will live as long as the pool. When
a max is specified, the "spawn" multiprocessing start method will be used by
default in absense of a *mp_context* parameter. This feature is incompatible
with the "fork" start method.
.. versionchanged:: 3.3
When one of the worker processes terminates abruptly, a