Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
Loading
from

Conversation

encukou
Copy link
Member

@encukou encukou commented May 17, 2025

Copy link
Member

@ZeroIntensity ZeroIntensity left a 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?

@encukou
Copy link
Member Author

encukou commented May 17, 2025

A better question is: do we guarantee that it will always stop the world?

@colesbury
Copy link
Contributor

colesbury commented May 17, 2025

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.

@ZeroIntensity
Copy link
Member

I think you might still need the locks in this example because of isolated sub interpreters each with their own GIL.

Subinterpreters switch to the main interpreter to import an extension, so the GIL synchronizes it.

@encukou
Copy link
Member Author

encukou commented May 17, 2025

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?
If you know the current implementation details, it's easy to leave this out.

@ZeroIntensity
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.