-
-
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
base: main
Are you sure you want to change the base?
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. |
📚 Documentation preview 📚: https://cpython-previews--134141.org.readthedocs.build/