You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ProcessPoolExecutor: pending futures never complete if executor is gc'd while a max_tasks_per_child= worker exits #152967
If the last reference to a ProcessPoolExecutor is dropped without calling shutdown() while queued work remains, and a worker exits upon reaching its max_tasks_per_child limit, the remaining futures never complete and interpreter exit hangs joining the executor manager thread.
Once the executor object has been collected, the weakref returns None and no replacement can ever be spawned. The manager thread then waits forever: pending work items remain (their calls are queued but no worker exists), so it never reaches the empty-pending exit condition, the futures are never resolved and never marked broken, and _python_exit() blocks joining the manager thread at interpreter exit.
Dropping an executor without shutdown() while holding its futures is otherwise supported: with max_tasks_per_child unset, the same program completes normally because the workers stay alive and drain the queue. Only the worker-exits-at-limit case strands work.
Suggested direction: when the manager observes a process exit while the executor weakref is dead, and no live workers remain while work items are pending, fail the pending work items with BrokenProcessPool instead of waiting forever.
Found independently by Claude Fable 5 while I had it test and update the gh-115634 fix (GH-140900).
This reproduces identically before and after that fix -- the replacement path cannot help because there is no executor left to spawn through. The relevant code shape is unchanged since max_tasks_per_child was added in 3.11.
See also #83386 for an older exit-hang of a different mechanism.
I would like to backport this further, but lets let this bake in a couple of 3.15 beta releases first as max_tasks_per_child= feature working usably enough at all was only just fixed in the first place.
Activity
gh-119592: gh-152967: Fix ProcessPoolExecutor stranding submitted wor…
[3.15] gh-119592: gh-152967: Fix ProcessPoolExecutor stranding submit…
gpshead commentedon Jul 8, 2026
I would like to backport this further, but lets let this bake in a couple of 3.15 beta releases first as max_tasks_per_child= feature working usably enough at all was only just fixed in the first place.
[3.14] gh-119592: gh-152967: Fix ProcessPoolExecutor stranding submit…