Skip to content

Conversation

oschwald
Copy link
Member

@oschwald oschwald commented Oct 10, 2025

  • Add free-threading support for Python 3.13+
  • Add some docs about thread safety
  • Fix wheel deprecation warning
  • Remove conditional logic for unsupported setuptools versions
  • Require Python 3.10+
  • Add threading test for C extension
  • Use modern union syntax throughout

Closes #249.

@oschwald oschwald force-pushed the greg/eng-2546 branch 11 times, most recently from 527162b to 6da0cf6 Compare October 10, 2025 19:27
Implements thread-safe concurrent database operations for Python's
free-threading mode using native locks where available.

- Uses native RW locks (pthread_rwlock_t on POSIX, SRWLOCK on Windows)
  to allow multiple concurrent readers
- Uses GIL on platforms that don't support these native locks
- Zero overhead when GIL is enabled (macros compile to no-ops)
We already have some threading coverage in the general reader tests,
but this provides more detailed implementation tests for the extension.
To ensure we are forcing correct checks in CI
The C extension was being built but not imported during tests due to
Python's sys.path ordering. The project root directory was appearing
first in sys.path, causing Python to import from the source directory
(which doesn't have the compiled .so file) instead of the installed
package in site-packages.

Changes:
- Add pytest --import-mode=importlib to prevent pytest from adding the
  project root to sys.path, ensuring tests import from the installed
  package in the tox virtualenv
- Add MAXMINDDB_REQUIRE_EXTENSION=1 to the "Setup test suite" step to
  ensure the extension is built during CI setup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant