Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.12] gh-113964: Don't prevent new threads until all non-daemon threads exit (GH-116677) #117029

Merged
merged 1 commit into from Mar 19, 2024

Conversation

colesbury
Copy link
Contributor

@colesbury colesbury commented Mar 19, 2024

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 60e105c)

…n threads exit (pythonGH-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.
(cherry picked from commit 60e105c)

Co-authored-by: Sam Gross <colesbury@gmail.com>
@colesbury colesbury requested a review from gpshead as a code owner March 19, 2024 19:02
@colesbury colesbury merged commit 9256433 into python:3.12 Mar 19, 2024
28 checks passed
@colesbury colesbury deleted the backport-60e105c-3.12 branch March 19, 2024 19:22
ppigazzini added a commit to ppigazzini/fishtest that referenced this pull request Apr 4, 2024
Python 3.12 introduced a bug during the interpreter shutdown, see:
- issue python/cpython#104826
- bugfix python/cpython#117029

With Python 3.12.3, this change could potentially be reverted (after testing).
ppigazzini added a commit to official-stockfish/fishtest that referenced this pull request Apr 4, 2024
Python 3.12 introduced a bug during the interpreter shutdown, see:
- issue python/cpython#104826
- bugfix python/cpython#117029

With Python 3.12.3, this change could potentially be reverted (after testing).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant