FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-104341: Wait Completely at threading._shutdown() by ericsnowcurrently · Pull Request #104672 · python/cpython · GitHub

/ cpython Public

gh-104341: Wait Completely at threading._shutdown() - #104672

Closed
ericsnowcurrently wants to merge 3 commits into
python:mainfrom
ericsnowcurrently:fix-threading-module-shutdown-simpler
Closed

gh-104341: Wait Completely at threading._shutdown()#104672
ericsnowcurrently wants to merge 3 commits into
python:mainfrom
ericsnowcurrently:fix-threading-module-shutdown-simpler

Conversation

ericsnowcurrently commented May 19, 2023
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Member

(This should solve the semi-frequent buildbot failures we've been seeing.)

In Py_EndInterpreter() we almost immediately wait for all non-daemon Python threads to finish, by calling theading._shutdown(). However, with a per-interpreter GIL there's a race because threading._shutdown() doesn't wait long enough. This change fixes that by making sure _PyThreadState_DeleteCurrent() completely finishes before releasing the lock on which threading._shutdown() depends.

The gist of it is that we release that lock (and clean it up) later than we would normally be able to, by doing the cleanup in another thread via a "pending" call.

This isn't an ideal solution, but other approaches I tried involved more invasive changes, which I'd like to avoid this close to the beta 1 release.

Copy link
Copy Markdown
Member Author

I plan on revisiting this problem, to introduce a better long-term solution. However, that probably won't be in 3.12.

ericsnowcurrently force-pushed the fix-threading-module-shutdown-simpler branch from 6c79a9b to 8b42a15 Compare May 23, 2023 21:00
ericsnowcurrently marked this pull request as ready for review May 23, 2023 21:01

Copy link
Copy Markdown
Member

Ae you still going with this, or has it been superseded?

Copy link
Copy Markdown
Member Author

It's superseded for the moment. I'm likely to revisit this for 3.13.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL