You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Interpreter shutdown can deadlock when a daemon thread holds the warnings lock #159485
3.14bugs and security fixes3.15bugs and security fixes3.16new features, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error
A daemon thread can be stopped while holding the warnings lock. During interpreter finalization, garbage collection triggers a ResourceWarning, deadlocking the finalizing thread:
I updated the reproducer script in the issue to avoid an unbounded wait (it now just does time.sleep(0.1) like test_threading does). This is more realistic and is fixed by @ZeroIntensity's InterpreterGuard approach. There's no need to guard against waiting forever in a callback like my original reproducer was arguing for. There's still a deadlock even without that and the InterpreterGuard fixes it.
Version-scope data point: the reproducer hangs on 3.14.5 Windows but exits normally on 3.13.14.
I ran the script from the issue (with the original 0.5 s hold) under an external 20 s timeout on two GIL builds:
3.13.14 (MSC v.1944, 64-bit Windows): printed the final message and exited normally, EXIT_CODE=0.
3.14.5 (MSC v.1944, 64-bit Windows): printed reached end of module; interpreter should now finalize, then never exited; killed at 20 s, EXIT_CODE=124.
The issue labels already list 3.14/3.15/3.16, so this is consistent — but the explicit 3.13 negative result may be useful when deciding where to backport the InterpreterGuard fix. It confirms the regression boundary is between 3.13 and 3.14 rather than being a long-standing issue.
This is relevant in practice for applications with many daemon threads: a desktop app with 20+ daemon workers and an atexit shutdown hook will occasionally leave a process alive after the window closes, which is easy to misdiagnose as a UI-framework shutdown bug.
No change requested — just adding the Windows data point and the 3.13 control result.
3.14bugs and security fixes3.15bugs and security fixes3.16new features, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error
Activity
pythongh-159485: Fix warnings lock deadlock during interpreter shutdown
ngoldbaum commentedon Oct 16, 2026
I updated the reproducer script in the issue to avoid an unbounded wait (it now just does
time.sleep(0.1)liketest_threadingdoes). This is more realistic and is fixed by @ZeroIntensity's InterpreterGuard approach. There's no need to guard against waiting forever in a callback like my original reproducer was arguing for. There's still a deadlock even without that and the InterpreterGuard fixes it.pythongh-159485: Hold an interpreter guard while using the warnings lock
pythongh-159485: Use the public interpreter guard API for the warning…
daneeller commentedon Nov 22, 2026
Version-scope data point: the reproducer hangs on 3.14.5 Windows but exits normally on 3.13.14.
I ran the script from the issue (with the original 0.5 s hold) under an external 20 s timeout on two GIL builds:
EXIT_CODE=0.reached end of module; interpreter should now finalize, then never exited; killed at 20 s,EXIT_CODE=124.The issue labels already list 3.14/3.15/3.16, so this is consistent — but the explicit 3.13 negative result may be useful when deciding where to backport the InterpreterGuard fix. It confirms the regression boundary is between 3.13 and 3.14 rather than being a long-standing issue.
This is relevant in practice for applications with many daemon threads: a desktop app with 20+ daemon workers and an
atexitshutdown hook will occasionally leave a process alive after the window closes, which is easy to misdiagnose as a UI-framework shutdown bug.No change requested — just adding the Windows data point and the 3.13 control result.