Skip to content

Make it compatible with Free Threading (aka no-gil) #297

Open

Description

@thepabloaguilar

Since Python 3.14 the no-gil feature is not experimental anymore but optional, when some of the dependencies are not marked that can run safely in those versions Python interpreter fallback to the default mode with GIL. This can impact when running on production but also when running tests:

<frozen importlib._bootstrap>:491: RuntimeWarning: The global interpreter lock (GIL) has been enabled to load module 'grimp._rustgrimp', which has not declared that it can run safely without the GIL. To override this behavior and keep the GIL disabled (at your own risk), run with PYTHON_GIL=0 or -Xgil=0.

It would be nice if this lib could be compatible with no-gil, if needed I can try to help!

Activity

  1. seddonym commented on Jan 22, 2026

    @seddonym
    Collaborator

    Thanks for the issue, I would like to support free threading but am not sure what is involved or how much work it is.

    Any input on that welcome!

  2. thepabloaguilar commented on Jan 25, 2026

    @thepabloaguilar
    Author

    We may want to add a test like this later:

    import sys
    import sysconfig
    
    # Just importing should be enough for the test
    import grimp
    
    # it should only run for Python 3.14t+
    def test_ensure_disabled_gil():
        assert sysconfig.get_config_var("Py_GIL_DISABLED") == 1:
        assert sys._is_gil_enabled() is False

    Source: Identifying free-threaded Python

  3. thepabloaguilar commented on Jan 25, 2026

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions