gh-143620: Fix race condition in test_traceback_when_child_process_terminates_abruptly#143621
gh-143620: Fix race condition in test_traceback_when_child_process_terminates_abruptly#143621a12k wants to merge 1 commit into
Conversation
|
I think the race condition analysis here may be slightly off. Looking at The actual issue seems to be that when A A fix in for p in self.processes.values():
p.join(timeout=3)
if p.exitcode is not None and p.exitcode != 0:
errors.append(...)The sentinel has already fired at this point so |
|
This PR is stale because it has been open for 30 days with no activity. |
Fixes gh-143620
There is a race condition in
test_concurrent_futures.test_process_pool. The test asserts that aBrokenProcessPoolexception has a__cause__immediately afterfuture.result()raises.In
concurrent.futures.process, the_terminate_brokenmethod sets the exception on the future before it attaches the_RemoteTracebackto the__cause__attr. Sometimes the test thread wakes up and inspects the exception while__cause__is stillNone, which leads to a test failure. I was able to repro (see issue for more details) by injecting a delay in_terminate_brokenbetween theset_exception()call and the__cause__assignment. This causes a 100% failure rate withAssertionError: None is not an instance of _RemoteTraceback.My proposed fix is to update the test to use
support.sleeping_retryto wait for the__cause__to be populated. This seems to be the pattern elsewhere in the test suite.