Skip to content

gh-161931: Wake up process manager after spawning workers - #161953

Open
Seemanshi2104 wants to merge 2 commits into
python:mainfrom
Seemanshi2104:gh-161931-manager-wakeup
Open

Seemanshi2104 wants to merge 2 commits into
python:mainfrom
Seemanshi2104:gh-161931-manager-wakeup

Conversation

@Seemanshi2104

@Seemanshi2104 Seemanshi2104 commented Nov 13, 2026 •

Copy link
Copy Markdown

ProcessPoolExecutor.submit() currently wakes the manager thread before spawning a worker. The manager can rebuild its wait set during that gap, leaving it unaware of the new worker's sentinel and unable to promptly detect when that worker exits.

This change adjusts the process count before waking the manager. The wake-up remains in a finally block so it still occurs if spawning raises. A synchronized regression test recreates the stale wait-set ordering, terminates the newly spawned worker, and verifies that the pending future raises BrokenProcessPool.

Fixes #161931

Tests:

  • ./python -m test -v test_concurrent_futures.test_process_pool — passed (144 tests, 16 skipped).
  • ./python -m test -v test_concurrent_futures.test_deadlock test_concurrent_futures.test_shutdown — passed (101 tests, 2 skipped).
  • The new regression test fails with the original ordering in both spawn and forkserver, and passes with this change.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@python-cla-bot

python-cla-bot Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app

bedevere-app Bot commented Nov 13, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ProcessPoolExecutor: a worker spawned on demand by submit() can die unnoticed (no BrokenProcessPool, hang) with forkserver/spawn

1 participant