Skip to content

Add sys._is_gil_enabled() #117514

Description

@colesbury

Feature or enhancement

I propose adding a new function to the sys module to check if the GIL is current enabled:

sys._is_gil_enabled() -> bool

Return True if the GIL is currently enabled and False if the GIL is currently disabled.

The function would always return True in builds that do not support free-threading. In the free-threaded build, the the GIL might be dynamically enabled or disabled depending on imported modules.

EDIT: Changed name to use underscore prefix

Linked PRs

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions