Skip to content

bpo-19466: Py_Finalize() clears daemon threads earlier #18848

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

Merged
merged 1 commit into from
Mar 9, 2020
Merged

bpo-19466: Py_Finalize() clears daemon threads earlier #18848

merged 1 commit into from
Mar 9, 2020

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants