Skip to content

gh-116167: Allow disabling the GIL with PYTHON_GIL=0 or -X gil=0#116338

Merged
colesbury merged 11 commits intopython:mainfrom
swtaarrs:cpython-disable-gil
Mar 11, 2024
Merged

gh-116167: Allow disabling the GIL with PYTHON_GIL=0 or -X gil=0#116338
colesbury merged 11 commits intopython:mainfrom
swtaarrs:cpython-disable-gil

Conversation

@swtaarrs
Copy link
Member

@swtaarrs swtaarrs commented Mar 4, 2024

In free-threaded builds, running with PYTHON_GIL=0 or -X gil=0 will now disable the GIL. #116322 and #116329 track follow-up work to re-enable the GIL when loading an incompatible extension, and to disable the GIL by default, respectively.

In order to support re-enabling the GIL at runtime, all GIL-related data structures are initialized as usual, and disabling the GIL simply sets a flag at startup that causes take_gil() and drop_gil() to return early.

With PYTHON_GIL=0 set, I spot-checked a few tests and small programs that don't use threads. They all seem to run fine, and very basic threaded programs work, sometimes. Trying to run the full test suite crashes pretty quickly, in test_asyncio.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants