Skip to content

Thread-safety of maxminddb C extension with Python free-threaded (no-GIL) build #249

@otsuka

Description

@otsuka

Hi team,

When importing maxminddb on Python’s experimental free-threaded build, I see a warning stating that the GIL has been enabled because the module hasn’t declared that it can run safely without the GIL.

Is the maxminddb C extension actually safe to use in a multi-threaded context when the interpreter is running without the GIL?

% python
Python 3.13.7 experimental free-threading build (main, Aug 30 2025, 00:32:10) [Clang 17.0.0 (clang-1700.0.13.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import maxminddb
<frozen importlib._bootstrap>:488: RuntimeWarning: The global interpreter lock (GIL) has been enabled to load module 
'maxminddb.extension', 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.

Thanks!

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