Skip to content

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Mar 8, 2020

Clear the frames of daemon threads earlier during the Python shutdown to
call objects destructors. So "unclosed file" resource warnings are now
emitted for daemon threads in a more reliable way.

Cleanup _PyThreadState_DeleteExcept() code: rename "garbage" to
"list".

https://bugs.python.org/issue19466

@vstinner vstinner changed the title bpo-19466: Py_Finalize() clears daemon threads earlier [WIP] bpo-19466: Py_Finalize() clears daemon threads earlier Mar 8, 2020
@vstinner
Copy link
Member Author

vstinner commented Mar 8, 2020

Oh, this change does not work as expected, it does introduce a crash, see:
https://bugs.python.org/issue19466#msg363654

It seems like the commit eb4e2ae (bpo-39877) introduced a race condition.

@vstinner
Copy link
Member Author

vstinner commented Mar 9, 2020

Oh, this change does not work as expected, it does introduce a crash, see:
https://bugs.python.org/issue19466#msg363654
It seems like the commit eb4e2ae (bpo-39877) introduced a race condition.

I wrote PR #18854 to fix this bug.

Clear the frames of daemon threads earlier during the Python shutdown to call objects destructors. So "unclosed file" resource warnings are now emitted for daemon threads in a more reliable way. Cleanup _PyThreadState_DeleteExcept() code: rename "garbage" to "list".
@vstinner vstinner changed the title [WIP] bpo-19466: Py_Finalize() clears daemon threads earlier bpo-19466: Py_Finalize() clears daemon threads earlier Mar 9, 2020
@vstinner vstinner merged commit 9ad58ac into python:master Mar 9, 2020
@vstinner vstinner deleted the finalize_daemon_threads branch March 9, 2020 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants