Skip to content

[Python] Do not fall back to the GIL on free-threaded Python#22548

Open
guitargeek wants to merge 1 commit into
root-project:masterfrom
guitargeek:disable_gil
Open

[Python] Do not fall back to the GIL on free-threaded Python#22548
guitargeek wants to merge 1 commit into
root-project:masterfrom
guitargeek:disable_gil

Conversation

@guitargeek

Copy link
Copy Markdown
Contributor

On a free-threaded ("GIL-less") Python build, importing a C extension module that does not explicitly declare free-threading support makes CPython re-enable the GIL at runtime and print a warning. Mark both the CPyCppyy module and the ROOT pythonizations module with Py_MOD_GIL_NOT_USED via PyUnstable_Module_SetGIL so that importing ROOT no longer forces the GIL back on.

The calls are guarded by Py_GIL_DISABLED and therefore have no effect on regular GIL-enabled builds.

Note that this is a declaration of intent, not a guarantee of full thread-safety: ROOT's interpreter and global state have not yet been audited for concurrent use, so unsynchronized multithreaded access may still produce wrong results or crashes. The purpose of the change is to signal our commitment to supporting free-threaded Python and to encourage users to run multithreaded workloads and report issues, so that the remaining thread-safety problems can be surfaced and fixed.

On a free-threaded ("GIL-less") Python build, importing a C extension
module that does not explicitly declare free-threading support makes
CPython re-enable the GIL at runtime and print a warning. Mark both the
CPyCppyy module and the ROOT pythonizations module with
Py_MOD_GIL_NOT_USED via PyUnstable_Module_SetGIL so that importing ROOT
no longer forces the GIL back on.

The calls are guarded by Py_GIL_DISABLED and therefore have no effect on
regular GIL-enabled builds.

Note that this is a declaration of intent, not a guarantee of full
thread-safety: ROOT's interpreter and global state have not yet been
audited for concurrent use, so unsynchronized multithreaded access may
still produce wrong results or crashes. The purpose of the change is to
signal our commitment to supporting free-threaded Python and to
encourage users to run multithreaded workloads and report issues, so
that the remaining thread-safety problems can be surfaced and fixed.
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

Test Results

    22 files      22 suites   3d 15h 54m 0s ⏱️
 3 861 tests  3 855 ✅   0 💤 6 ❌
76 285 runs  76 177 ✅ 102 💤 6 ❌

For more details on these failures, see this check.

Results for commit 7ac7cd3.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant