Skip to content

Allow C extensions to declare compatibility with free-threading #116322

Closed
@swtaarrs

Description

@swtaarrs
Member

Feature or enhancement

There are a few pieces to this:

  1. Add a Py_mod_gil slot, as described in PEP 703, that multi-phase init modules can use to indicate that they support free-threading.
  2. Add a PyModule_ExperimentalSetGIL() function (discussed here) that single-phase init modules can use in place of Py_mod_gil.
  3. Mark all built-in modules as free-threading compatible with one of the above mechanisms.
  4. Enable the GIL while loading a C module and leave it permanently enabled if the module does not declare free-threading compatibility.

1-3 are addressed in gh-116882; 4 will be addressed in a separate PR.

Linked PRs

Activity

self-assigned this
on Mar 11, 2024
swtaarrs

swtaarrs commented on Mar 11, 2024

@swtaarrs
MemberAuthor

What warning category should this issue? ImportWarning sounds like a good fit at first, but it's ignored by the default warning filters, which we don't want. Of the categories not ignored by default, RuntimeWarning seems like the best fit to me.

changed the title [-]Implement `Py_mod_gil` slot for free-threading-safe extensions[/-] [+]Allow C extensions to declare compatibility with free-threading[/+] on May 2, 2024
added a commit that references this issue on May 3, 2024

gh-116322: Add Py_mod_gil module slot (#116882)

c2627d6
added a commit that references this issue on May 6, 2024

pythongh-116322: Rename PyModule_ExperimentalSetGIL to PyUnstable_Mod…

18 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @swtaarrs@colesbury

      Issue actions

        Allow C extensions to declare compatibility with free-threading · Issue #116322 · python/cpython