]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.13] gh-115634: Fix ProcessPoolExecutor deadlock with max_tasks_per_child (GH-14090...
authorGregory P. Smith <68491+gpshead@users.noreply.github.com>
Fri, 3 Jul 2026 07:04:56 +0000 (00:04 -0700)
committerGitHub <noreply@github.com>
Fri, 3 Jul 2026 07:04:56 +0000 (07:04 +0000)
commit618ce0a393a17d470d841bfe2767e85cb56560b5
tree044cb3d771e457444c2e60efb6a42d3b3c0709c4
parentda2cb8f66231fb103ff83aa78f64c9744db1a207
[3.13] gh-115634: Fix ProcessPoolExecutor deadlock with max_tasks_per_child (GH-140900) (#152928)

The idle worker semaphore counts task completions, not idle workers, so
it can hold a stale token released by a worker that later exited upon
reaching its max_tasks_per_child limit. The worker replacement path
consumed such tokens and skipped spawning a replacement, deadlocking
the remaining queued tasks once no workers were left.

Replace dead workers based on len(self._processes) without consulting
the semaphore. The submit() path is unchanged, preserving on-demand
spawning and idle worker reuse.

Replace the documentation note added in GH-140897 with a versionchanged
entry now that the bug is fixed.

Based on a fix proposed by Tabrez Mohammed.

(cherry picked from commit b706767d8fd7d21afc3f156fb9c173bc99855e0e)
Doc/library/concurrent.futures.rst
Lib/concurrent/futures/process.py
Lib/test/test_concurrent_futures/test_process_pool.py
Misc/NEWS.d/next/Library/2025-11-02-05-28-56.gh-issue-115634.JbcNnF.rst [new file with mode: 0644]