The test_3_join_in_forked_from_thread test case in test_threading.py may call fork during shutdown:
|
@skip_unless_reliable_fork |
|
def test_3_join_in_forked_from_thread(self): |
|
# Like the test above, but fork() was called from a worker thread |
The relevant code looks like:
def worker():
childpid = os.fork()
...
w = threading.Thread(target=worker)
w.start()
The interpreter starts shutting down immediately after w.start(). In the default build, this is usually OK because the GIL switching interval (and limited eval breaker checks) means that the os.fork() call likely happens before the w.start() returns, but there is no guarantee of that. In the free-threaded build, this is much more likely to raise a PythonFinalizationError: can't fork at interpreter shutdown error because the w.start() call returns more quickly.
See also #114570
Linked PRs
The
test_3_join_in_forked_from_threadtest case intest_threading.pymay call fork during shutdown:cpython/Lib/test/test_threading.py
Lines 1273 to 1275 in 113053a
The relevant code looks like:
The interpreter starts shutting down immediately after
w.start(). In the default build, this is usually OK because the GIL switching interval (and limited eval breaker checks) means that theos.fork()call likely happens before thew.start()returns, but there is no guarantee of that. In the free-threaded build, this is much more likely to raise aPythonFinalizationError: can't fork at interpreter shutdownerror because thew.start()call returns more quickly.See also #114570
Linked PRs