Repository navigation
Fix flaky test_interrupt_stops_workers on Python 3.10 - #567
Merged
Merged
Conversation
After an interrupt, parallel_map terminates and joins the workers, but the executor's manager thread may join them at the same time. Only one of the two gets the exit status from the OS; if it's the manager thread, the worker has exited and been reaped, but multiprocessing.active_children() still lists it until the manager thread has recorded its exit code (at most ~1 ms later). The test checked immediately, and failed in about 1 of 3 runs on Python 3.10. Allow a short delay (at most 5 s). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
gmloose
added a commit
that referenced
this pull request
Nov 9, 2026
After an interrupt, parallel_map terminates and joins the workers, but the executor's manager thread may join them at the same time. Only one of the two gets the exit status from the OS; if it's the manager thread, the worker has exited and been reaped, but multiprocessing.active_children() still lists it until the manager thread has recorded its exit code (at most ~1 ms later). The test checked immediately, and failed in about 1 of 3 runs on Python 3.10. Allow a short delay (at most 5 s). Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Python 3.10,
test_interrupt_stops_workersintest/tmulti_proc.pyfails intermittently with "workers still running". Locally it failed in 8 of 20 runs (withmaster'smulti_proc.py). The wheel builds run this test on cp310.Cause
After the interrupt,
parallel_mapterminates and joins its workers, and the executor's manager thread joins the same workers (join_executor_internalsinconcurrent.futures.process). Only one of the two threads gets the exit status from the OS (waitpid). The other getsECHILD, whichPopen.poll()turns into "no exit code yet", so itsjoin()returns without an exit code.If the manager thread wins, the worker has exited and been reaped, but
multiprocessing.active_children()still lists it until the manager thread has stored the exit code. Instrumenting_terminate_workersshowed exactly this: after itsjoin()calls, one worker had exit codeNone, and a moment lateractive_children()was empty.The delay is at most about 1 ms (measured over 30 runs). The test checked
active_children()immediately afterparallel_mapreturned, so it sometimes failed. The race exists in other Python versions too, but the timing made it show up on 3.10.Fix
parallel_mapbehaves correctly: when it re-raises, all workers have been terminated and have exited. Only the test changes: it waits foractive_children()to become empty, for at most 5 s, before asserting. That's far more than the ~1 ms delay, and much less than the 60-second tasks, so a worker that is really still running still fails the test.Testing
tmulti_proc.pypasses on Python 3.10, 3.11, 3.12, 3.13 and 3.14.This is independent of #566 (the fork deadlock in
test_overlapping_calls); both PRs change different parts oftmulti_proc.py.🤖 Generated with Claude Code