-
-
Notifications
You must be signed in to change notification settings - Fork 32k
Add notes on nogil & reinitialization to the Opt-Out section in Module Isolation HOWTO #134141
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't free-threading perform a stop-the-world when importing modules?
A better question is: do we guarantee that it will always stop the world? |
We stop the world, temporarily enable the GIL, then resume (but with only one thread now holding the GIL), and the run the C extension initialization code. I think you might still need the locks in this example because of isolated sub interpreters each with their own GIL. We haven't explicitly guaranteed the stop the world behavior, but it'll probably be difficult to change in the future. |
Subinterpreters switch to the main interpreter to import an extension, so the GIL synchronizes it. |
Well, that's something I'd like to change for 3.15 :) Let's play it safe and keep our options open? |
I'll yield, but I'm worried that it would break too much code to be feasible (or worth doing). I think all third-party extensions currently assume no other threads, right? Maybe we could make this opt-in. |
Thanks @encukou for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13. |
Thanks @encukou for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14. |
…e Isolation HOWTO (pythonGH-134141) (cherry picked from commit 1f0a294) Co-authored-by: Petr Viktorin <[email protected]> Co-authored-by: Sam Gross <[email protected]>
…e Isolation HOWTO (pythonGH-134141) (cherry picked from commit 1f0a294) Co-authored-by: Petr Viktorin <[email protected]> Co-authored-by: Sam Gross <[email protected]>
GH-134491 is a backport of this pull request to the 3.13 branch. |
GH-134492 is a backport of this pull request to the 3.14 branch. |
…n Module Isolation HOWTO (GH-134141) (GH-134492) Add notes on nogil & reinitialization to the Opt-Out section in Module Isolation HOWTO (GH-134141) (cherry picked from commit 1f0a294) Co-authored-by: Petr Viktorin <[email protected]> Co-authored-by: Sam Gross <[email protected]>
…n Module Isolation HOWTO (GH-134141) (GH-134491) Add notes on nogil & reinitialization to the Opt-Out section in Module Isolation HOWTO (GH-134141) (cherry picked from commit 1f0a294) Co-authored-by: Petr Viktorin <[email protected]> Co-authored-by: Sam Gross <[email protected]>
📚 Documentation preview 📚: https://cpython-previews--134141.org.readthedocs.build/