Daemon threads are not forced to exit as part of runtime finalization #124149
Labels
3.14
new features, bugs and security fixes
topic-free-threading
type-bug
An unexpected behavior, bug, or error
Bug report
Bug description:
Daemon threads are forced to exit during finalization in default builds:
cpython/Python/pylifecycle.c
Lines 2023 to 2026 in 10de360
Such threads will exit immediately the next time that they acquire the GIL:
cpython/Python/ceval_gil.c
Lines 294 to 302 in 10de360
I don't believe daemon threads are forced to exit in the free-threaded builds. If you run the following script under GDB:
and break immediately before
_Py_Finalize
returns, the daemon thread will be blocked intstate_wait_attach
:Assuming this is correct, finalizers that run during runtime finalization cannot safely join daemon threads. I'm not sure if this is something we want to support in the free-threaded build, but I thought it was worth documenting since it's a behavioral difference from the default build.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
The text was updated successfully, but these errors were encountered: