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

Add notes on nogil & reinitialization to the Opt-Out section in Module Isolation HOWTO by encukou · Pull Request #134141 · python/cpython · GitHub

Repository navigation

Add notes on nogil & reinitialization to the Opt-Out section in Module Isolation HOWTO - #134141

Merged
encukou merged 2 commits into
python:mainfrom
encukou:isolating-opt-out
May 22, 2025
Merged

encukou merged 2 commits into
python:mainfrom
encukou:isolating-opt-out

Conversation

encukou commented May 17, 2025 •
edited by github-actions Bot
Loading

Copy link
Copy Markdown
Member

ZeroIntensity left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Doesn't free-threading perform a stop-the-world when importing modules?

encukou commented May 17, 2025

Copy link
Copy Markdown
Member Author

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

Comment thread Doc/howto/isolating-extensions.rst Outdated

colesbury commented May 17, 2025 •
edited
Loading

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
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.

Comment thread Doc/howto/isolating-extensions.rst Outdated
Comment thread Doc/howto/isolating-extensions.rst Outdated

encukou commented May 17, 2025

Copy link
Copy Markdown
Member Author

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.

Copy link
Copy Markdown
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.

encukou merged commit 1f0a294 into python:main May 22, 2025
github-project-automation Bot moved this from Todo to Done in Docs PRs May 22, 2025
encukou deleted the isolating-opt-out branch May 22, 2025 07:36
encukou added needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes labels May 22, 2025

Copy link
Copy Markdown

Thanks @encukou for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

Copy link
Copy Markdown

Thanks @encukou for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 22, 2025
…e Isolation HOWTO (pythonGH-134141)

(cherry picked from commit 1f0a294)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Sam Gross <colesbury@gmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 22, 2025
…e Isolation HOWTO (pythonGH-134141)

(cherry picked from commit 1f0a294)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Sam Gross <colesbury@gmail.com>

bedevere-app Bot commented May 22, 2025

Copy link
Copy Markdown

GH-134491 is a backport of this pull request to the 3.13 branch.

bedevere-app Bot removed the needs backport to 3.13 only security fixes label May 22, 2025

bedevere-app Bot commented May 22, 2025

Copy link
Copy Markdown

GH-134492 is a backport of this pull request to the 3.14 branch.

bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label May 22, 2025
encukou added a commit that referenced this pull request May 22, 2025
…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 <encukou@gmail.com>
Co-authored-by: Sam Gross <colesbury@gmail.com>
encukou added a commit that referenced this pull request May 23, 2025
…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 <encukou@gmail.com>
Co-authored-by: Sam Gross <colesbury@gmail.com>
lkollar pushed a commit to lkollar/cpython that referenced this pull request May 26, 2025
…e Isolation HOWTO (pythonGH-134141)

Co-authored-by: Sam Gross <colesbury@gmail.com>
Pranjal095 pushed a commit to Pranjal095/cpython that referenced this pull request Jul 12, 2025
…e Isolation HOWTO (pythonGH-134141)

Co-authored-by: Sam Gross <colesbury@gmail.com>
taegyunkim pushed a commit to taegyunkim/cpython that referenced this pull request Aug 4, 2025
…e Isolation HOWTO (pythonGH-134141)

Co-authored-by: Sam Gross <colesbury@gmail.com>
gostak-dd pushed a commit to gostak-dd/cpython that referenced this pull request Jun 2, 2026
…e Isolation HOWTO (pythonGH-134141)

Co-authored-by: Sam Gross <colesbury@gmail.com>
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

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL