Title: Race condition in test_traceback_when_child_process_terminates_abruptly · Issue #143620 · python/cpython · GitHub
Open Graph Title: Race condition in test_traceback_when_child_process_terminates_abruptly · Issue #143620 · python/cpython
X Title: Race condition in test_traceback_when_child_process_terminates_abruptly · Issue #143620 · python/cpython
Description: Bug report Bug description: I have been observing that on my local build of main branch when I run the test suite, I occasionally am getting a failed test. Failure here: 0:01:56 load avg: 2.52 [ 39/498] test.test_concurrent_futures.test_...
Open Graph Description: Bug report Bug description: I have been observing that on my local build of main branch when I run the test suite, I occasionally am getting a failed test. Failure here: 0:01:56 load avg: 2.52 [ 39...
X Description: Bug report Bug description: I have been observing that on my local build of main branch when I run the test suite, I occasionally am getting a failed test. Failure here: 0:01:56 load avg: 2.52 [ 39...
Opengraph URL: https://github.com/python/cpython/issues/143620
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Race condition in test_traceback_when_child_process_terminates_abruptly","articleBody":"# Bug report\n\n### Bug description:\n\nI have been observing that on my local build of main branch when I run the test suite, I occasionally am getting a failed test. Failure here:\n\n```\n0:01:56 load avg: 2.52 [ 39/498] test.test_concurrent_futures.test_interpreter_pool passed\n\n0:01:56 load avg: 2.52 [ 40/498] test.test_concurrent_futures.test_process_pool\n\ntest test.test_concurrent_futures.test_process_pool failed -- Traceback (most recent call last):\n\n File \"/Users/a12k/opt/cpython/Lib/test/test_concurrent_futures/test_process_pool.py\", line 119, in test_traceback_when_child_process_terminates_abruptly\n\n self.assertIsInstance(cause, futures.process._RemoteTraceback)\n\n ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nAssertionError: None is not an instance of \u003cclass 'concurrent.futures.process._RemoteTraceback'>\n\n0:02:08 load avg: 2.97 [ 40/498/1] test.test_concurrent_futures.test_process_pool failed (1 failure)\n0:02:08 load avg: 2.97 [ 41/498/1] test.test_concurrent_futures.test_shutdown\n```\n\nI tried a few different ways of repro-ing this deterministically, mostly letting it and the few tests that preceded it run for an hour (`./python.exe -m test -v -F test.test_concurrent_futures.test_process_pool`, or `./python -m test -v -F test_concurrent_futures.test_deadlock test_concurrent_futures.test_interpreter_pool test_concurrent_futures.test_process_pool`) until it failed. \n\nI ended up forcing the fail in `Lib/concurrent/futures/process.py` which is as follows (insert at line 486 right after `errors = []` all the way until `# Mark pending tasks as failed.`):\n\n```python\n if any(fn == os._exit for fn in [w.fn for w in self.pending_work_items.values()]):\n print(\"~~~ ARTIFICAL DELAY ~~~\")\n for p in list(self.processes.values()):\n # set exit code to None to simulate it not ready yet\n object.__setattr__(p, \"_exitcode\", None)\n\n for p in self.processes.values():\n if p.exitcode is not None and p.exitcode != 0:\n errors.append(f\"Process {p.pid} terminated abruptly \"\n f\"with exit code {p.exitcode}\")\n if errors:\n cause_str = \"\\n\".join(errors)\n\n if cause_str and any(fn == os._exit for fn in [w.fn for w in self.pending_work_items.values()]):\n print(\"~~~ ARTIFICAL DELAY ~~~ Waiting to set __cause__ for 3 seconds\")\n def delayed_set_cause():\n import time\n time.sleep(3)\n print(\"~~~ ARTIFICAL DELAY COMPLETE ~~~ setting __cause__\")\n nonlocal bpe\n bpe.__cause__ = _RemoteTraceback(f\"\\n'''\\n{cause_str}'''\")\n\n # Set cause after delay\n threading.Thread(target=delayed_set_cause, daemon=True).start()\n elif cause_str:\n bpe.__cause__ = _RemoteTraceback(f\"\\n'''\\n{cause_str}'''\")\n```\nBasically forcing the race condition, setting the cause to None and delaying it. Not sure if this was all necessary, but that's how I was able to deterministically get it to continually fail. \n\nI updated the test to account for this race condition by waiting for `__cause__` to be populated and now the test passes. PR incoming for review. \n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nmacOS\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-143621\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/a12k","@type":"Person","name":"a12k"},"datePublished":"2026-01-09T16:12:03Z","url":"https://github.com/python/cpython/issues/143620"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:3a60f744-d8ca-cb4b-d539-c76c2ebedae2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D404:1EC9BC:36CB5FB:45EAE36:6B01F40C |
| html-safe-nonce | 6b4094a9386fbd12811911037419f9db042738971fbaca18c9b2e46cb0e2e691 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENDA0OjFFQzlCQzozNkNCNUZCOjQ1RUFFMzY6NkIwMUY0MEMiLCJ2aXNpdG9yX2lkIjoiNDM1Mjc5MzE3NDEwMDUzODM4MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 9bd12f0b752fc36592319a0d085216774dc22591e0b1d649d0fd2fc7249767a1 |
| hovercard-subject-tag | issue:3797513325 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/143620/issue_layout |
| twitter:image | https://opengraph.githubassets.com/44538d460f8a33c687ca49131e5a8c4a40119fe2cd208c0c9a80719d7e53eb77/python/cpython/issues/143620 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/44538d460f8a33c687ca49131e5a8c4a40119fe2cd208c0c9a80719d7e53eb77/python/cpython/issues/143620 |
| og:image:alt | Bug report Bug description: I have been observing that on my local build of main branch when I run the test suite, I occasionally am getting a failed test. Failure here: 0:01:56 load avg: 2.52 [ 39... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | a12k |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width