Repository navigation
Description
Problem
crates/citry_core_py/src/lib.rs:57 declares the extension module #[pymodule(gil_used = true)]. On a free-threaded CPython build (3.14t, 3.15t), importing citry_core._rust turns the GIL back on for the whole process, unless PYTHON_GIL=0 is set. Python then warns:
RuntimeWarning: The global interpreter lock (GIL) has been enabled to load module 'citry_core._rust', which has not declared that it can run safely without the GIL.
So Citry users on free-threaded builds get a process that runs with the GIL. The weekly free-threaded test run (#264) shows the same thing.
The declaration exists because the native render code (citry_core._rust.native_render) reads Python dicts and lists without locking them. That is safe only under the GIL.
What already keeps free-threaded builds safe
packages/py/citry/citry/_vue/native_render.py:108 (_decide) refuses the native render path whenever the build has Py_GIL_DISABLED. It checks the build setting, not the runtime GIL state. A free-threaded build therefore always renders on the Python path and never calls native_render, even after the GIL comes back on.
Audit so far (read-only, not built)
native_renderreads containers without locking. Free-threaded builds never call it, because of the check above.native_render/runs.rs:505holds astatic SHARED_DATA: PyOnceLock<...>. PyO3 providesPyOnceLockfor free-threaded builds.- The
lazy_static!tables incitry_template_parser/src/constants.rs(lines 283, 451, 531) are read-only constants, and the macro requires them to beSync. - The
thread_local!RefCells incitry_html_transform/src/hydration_nesting.rs:157andcitry_vue_compiler/src/lib.rs:278each belong to a single thread. - No
static mutand nounsafe impl Sync/Sendappear in the crates.
Open item
Every PyO3 entry point that walks a Python dict or list argument needs checking: the extraction into Rust types, and any PyDict or PyList iteration outside native_render. PyO3 0.30 locks a dict while it iterates it on free-threaded builds. Code that holds a borrowed item across a call that can run Python code, or that reads a list's length and its items in separate steps, still needs a look.
Done when
- That open item is audited, and any container access that needs a lock is fixed.
- The module declares
gil_used = false. - The free-threaded run in Run the Python test suite on PyPy and free-threaded CPython #264 passes without the GIL. That run already includes a report-only
PYTHON_GIL=0step over the render, serialize, Events and thread tests.
Activity
JuroOravec commentedon Oct 27, 2026
Postponed until after 0.7.0, as the maintainer decided. Until then, a free-threaded build (cp314t, cp315t) installs and runs Citry with the GIL turned back on, and the weekly free-threaded run in #264 keeps a report-only
PYTHON_GIL=0step as evidence for this work.