diff options
author | Sam Gross <colesbury@gmail.com> | 2024-03-19 18:40:20 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-19 18:40:20 (GMT) |
commit | 60e105c1c11ecca1680d03c38aa06bcc77a28714 (patch) | |
tree | ec314b15b7739ae1f0c463ebd47cff1d06b4260e /Lib/test/test_subprocess.py | |
parent | 025ef7a5f7b424fba8713e448244b952bf897df3 (diff) | |
download | cpython-60e105c1c11ecca1680d03c38aa06bcc77a28714.zip cpython-60e105c1c11ecca1680d03c38aa06bcc77a28714.tar.gz cpython-60e105c1c11ecca1680d03c38aa06bcc77a28714.tar.bz2 |
gh-113964: Don't prevent new threads until all non-daemon threads exit (#116677)
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.
Diffstat (limited to 'Lib/test/test_subprocess.py')
-rw-r--r-- | Lib/test/test_subprocess.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py index d20b987..70452ca 100644 --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -3398,14 +3398,15 @@ class POSIXProcessTestCase(BaseTestCase): def dummy(): pass - def exit_handler(): - subprocess.Popen({ZERO_RETURN_CMD}, preexec_fn=dummy) - print("shouldn't be printed") - - atexit.register(exit_handler) + class AtFinalization: + def __del__(self): + print("OK") + subprocess.Popen({ZERO_RETURN_CMD}, preexec_fn=dummy) + print("shouldn't be printed") + at_finalization = AtFinalization() """ _, out, err = assert_python_ok("-c", code) - self.assertEqual(out, b'') + self.assertEqual(out.strip(), b"OK") self.assertIn(b"preexec_fn not supported at interpreter shutdown", err) @unittest.skipIf(not sysconfig.get_config_var("HAVE_VFORK"), |