]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.12] gh-113964: Don't prevent new threads until all non-daemon threads exit (GH...
authorSam Gross <colesbury@gmail.com>
Tue, 19 Mar 2024 19:22:42 +0000 (15:22 -0400)
committerGitHub <noreply@github.com>
Tue, 19 Mar 2024 19:22:42 +0000 (15:22 -0400)
commit92564331defba3462116d54658cd97624bb12678
treec9bfacbb39cbc98054602c90c84302301f22c6fc
parent4be9fa896117bf07dc944a29c98dd18b71dd6c74
[3.12] gh-113964: Don't prevent new threads until all non-daemon threads exit (GH-116677) (#117029)

Starting in Python 3.12, we prevented calling fork() and starting new threads
during interpreter finalization (shutdown). This has led to a number of
regressions and flaky tests. We should not prevent starting new threads
(or `fork()`) until all non-daemon threads exit and finalization starts in
earnest.

This changes the checks to use `_PyInterpreterState_GetFinalizing(interp)`,
which is set immediately before terminating non-daemon threads.

(cherry picked from commit 60e105c1c11ecca1680d03c38aa06bcc77a28714)
Lib/test/test_os.py
Lib/test/test_subprocess.py
Lib/test/test_threading.py
Misc/NEWS.d/next/Core and Builtins/2024-03-12-20-31-57.gh-issue-113964.bJppzg.rst [new file with mode: 0644]
Modules/_posixsubprocess.c
Modules/_threadmodule.c
Modules/posixmodule.c
Objects/unicodeobject.c