gh-101267: [bug] ProcessPoolExecutor should not share one BrokenProcessPool exception among all failed futures#101268
Conversation
|
Most changes to Python require a NEWS entry. Please add it using the blurb_it web app or the blurb command-line tool. |
…among all failed futures (python#101267)
2b2e712 to
4d97a88
Compare
|
Most changes to Python require a NEWS entry. Please add it using the blurb_it web app or the blurb command-line tool. |
|
Could you please take a look @gpshead? |
|
This PR is stale because it has been open for 30 days with no activity. |
1 similar comment
|
This PR is stale because it has been open for 30 days with no activity. |
Adapt the pythongh-101267 fix to the current code shape: * concurrent.futures.process.ProcessPoolExecutor._terminate_broken() was refactored (renamed from terminate_broken(), and gained the exit-code reporting from pythongh-139462). Reapply the fix on top: compute the broken-pool cause once, then create a fresh BrokenProcessPool exception per pending future inside the loop. Preserve the InvalidStateError guard around set_exception(). * Lib/test/test_concurrent_futures.py was split into a package. Move the new regression test into test_concurrent_futures/test_process_pool.py.
…ting Two refinements to the broken-pool handling: * submit() raises BrokenProcessPool(self._broken) so the message says why the pool broke, rather than a generic fixed string. * Build the cause traceback string once before the per-future loop instead of rebuilding the same f-string on every iteration.
…king * Block the workers on a never-set Event (via the harness create_event()) instead of submitting time.sleep(3): the sleep could finish before the worker is terminated on a loaded machine, completing the future and raising no BrokenProcessPool. * Use try/except/else with self.fail() rather than seeding count = None, so a missing exception is reported clearly. assertRaises() can't be used here because it strips the traceback the test needs to inspect.
Describe the actual failure (re-raising one shared exception appends a traceback to it on each Future.result()) and cross-reference the API names.
|
Thanks @daniel-shields for the PR, and @gpshead for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15. |
|
Sorry, @daniel-shields and @gpshead, I could not cleanly backport this to |
|
GH-151430 is a backport of this pull request to the 3.15 branch. |
…Pool exception among all failed futures (pythonGH-101268) (cherry picked from commit 3c00ebc) Co-authored-by: Daniel Shields <daniel.shields@twosigma.com> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Gregory P. Smith <greg@krypto.org>
…Pool exception among all failed futures (pythonGH-101268) (cherry picked from commit 3c00ebc) Co-authored-by: Daniel Shields <daniel.shields@twosigma.com> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Gregory P. Smith <greg@krypto.org>
|
GH-151431 is a backport of this pull request to the 3.14 branch. |
…sPool exception among all failed futures (GH-101268) (#151430) gh-101267: ProcessPoolExecutor no longer shares 1 BrokenProcessPool exception among all failed futures (GH-101268) (cherry picked from commit 3c00ebc) Co-authored-by: Daniel Shields <daniel.shields@twosigma.com> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Gregory P. Smith <greg@krypto.org>
…sPool exception among all failed futures (GH-101268) (#151431) * gh-101267: ProcessPoolExecutor no longer shares 1 BrokenProcessPool exception among all failed futures (GH-101268) (cherry picked from commit 3c00ebc) Co-authored-by: Daniel Shields <daniel.shields@twosigma.com> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Gregory P. Smith <greg@krypto.org> (cherry picked from commit 4e8c9c6) * Drop the abrupt-exit-code reporting from the 3.14 backport Reporting the exit codes of processes that died without a known cause is a new feature, not part of the gh-101267 bugfix. Keep only the bugfix on 3.14: each failed future gets its own BrokenProcessPool exception instead of one shared instance. --------- Co-authored-by: Daniel Shields <daniel.shields@twosigma.com> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
…sPool exception among all failed futures (GH-101268) (GH-151431) (#151435) [3.14] gh-101267: ProcessPoolExecutor no longer shares 1 BrokenProcessPool exception among all failed futures (GH-101268) (GH-151431) * gh-101267: ProcessPoolExecutor no longer shares 1 BrokenProcessPool exception among all failed futures (GH-101268) (cherry picked from commit 3c00ebc) (cherry picked from commit 4e8c9c6) * Drop the abrupt-exit-code reporting from the 3.14 backport Reporting the exit codes of processes that died without a known cause is a new feature, not part of the gh-101267 bugfix. Keep only the bugfix on 3.14: each failed future gets its own BrokenProcessPool exception instead of one shared instance. --------- (cherry picked from commit 27ff2c8) Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com> Co-authored-by: Daniel Shields <daniel.shields@twosigma.com> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Please see associated issue for details.