Skip to content

Support free threaded builds #292

Closed

Description

@geertj

Importing lz4 in a free-threaded Python re-enables the GIL with the following warning.

$ python
Python 3.13.0 experimental free-threading build (main, Oct 19 2024, 12:34:19) [GCC 11.4.1 20230605 (Red Hat 11.4.1-2)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import lz4
<frozen importlib._bootstrap>:488: RuntimeWarning: The global interpreter lock (GIL) has been enabled to load module 'lz4._version', 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.

Activity

  1. rgommers commented on Feb 18, 2025

    @rgommers

    Free-threading support would be great. I had a look at what it would take. The README says:
    "The bindings drop the GIL when calling in to the underlying LZ4 library, and is thread safe. An extensive test suite is included." and there aren't any open thread-safety issues - which looks like good news to me. The TODOs here should be something like:

    • Audit Python bindings and declare them free-threading compatible (xref https://py-free-threading.github.io/porting/#updating-extension-modules).
    • Run the test suite with pytest-run-parallel to find potential issues, and fix them.
    • Run the test suite under ThreadSanitizer. Should be feasible, since there are no runtime dependencies aside from CPython itself.
    • Add cp313t-* to CI to build free-threading wheels.

    Note that this is the first time I've looked at this repo, so I might be missing known issues or code that needs closer inspection. Any suggestions here will be very useful.

    Our team at Quansight working on free-threading support in widely used open source projects is happy to help and work on this. Please do let us know if you'd prefer us to hold off for any reason.

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