Skip to content

ci: test on the free-threaded build of Python 3.15 - #610

Draft
ap-- wants to merge 2 commits into
fsspec:mainfrom
ap--:ci-free-threaded-3.15t
Draft

ap-- wants to merge 2 commits into
fsspec:mainfrom
ap--:ci-free-threaded-3.15t

Conversation

@ap--

@ap-- ap-- commented Dec 5, 2026 •

Copy link
Copy Markdown
Collaborator

Follow-up to #608.

Runs the test suite on free-threaded CPython 3.15 (3.15t): nox -s tests-3.15t, plus one more ubuntu-latest entry in the CI test matrix.

nox

  • FREE_THREADED_PYTHONS = ["3.15t"] only extends the tests session. type-safety and type-checking keep using SUPPORTED_PYTHONS, since free-threaded builds type check like the regular build of the same version.
  • Environment markers can't tell free-threaded builds apart, so on these builds the session leaves out test dependencies without cp315t wheels via uv's --excludes:
    • gcsfs: imports grpcio, which has no wheels and is slow to build, so the gcs tests are skipped. The docker_gcs fixture now skips without gcsfs, because test_mkdir_in_empty_bucket used to fail instead of skipping.
    • hf-xet: building it needs a recent Rust. huggingface_hub works without it, so the hf tests still run.
  • PyNaCl (required by paramiko for sftp) has no cp315t wheels either, but builds from source with its bundled libsodium.

Results (Linux, without the SMB suite, which can't bind port 445 on my machine)

run passed skipped xfailed failed
3.15t 5418 150 73 0
3.15t with PYTHON_GIL=0 5375 150 116 0
3.15 (for comparison) 5557 12 72 0

The additional skips are the gcs tests. The additional xfails with PYTHON_GIL=0 are GitHub tests that hit the API rate limit. No extension module re-enables the GIL during the test run. I'm not adding the Free Threading trove classifier yet, because of the known registry race below.

Thread-safety fix

Concurrent first lookups of a protocol that fsspec knows but UPath doesn't implement (get_upath_class() creating the fallback class) created a separate class per thread. Paths created in different threads then failed to pickle (99 of 100 trials on 3.15t, 1 of 100 with the GIL), and relative_to() rejected them. All lookups now return the class registered in upath.implementations._experimental. test_get_upath_class_without_implementation_threaded fails on 3.15t without the fix.

Reviewed, but left as is:

  • _FSSPEC_HAS_WORKING_GLOB, _LISTDIR_WORKS_ON_FILES and _get_implementation_protocols() are idempotent lazy initializations.
  • WrappedFileSystemFlavour.from_protocol() can return two equal flavour instances during the first concurrent lookup. That's harmless in practice: only </> compare flavour identity, and the reflected comparison covers it.

Known, not fixed here:

  • register_implementation(..., clobber=True) clears the lookup cache before it writes the new entry, so a concurrent lookup can cache the old class. Fixing this needs a lock.
  • Unrelated to threads: registering a protocol after it was looked up doesn't clear the cache, so get_upath_class() keeps returning None.

Docs

docs/contributing.md: how to run nox -s tests-3.15t, and which dependencies are left out.

Not verified

  • The CI job runtime. The first PyNaCl build from source needs to fit into the 10 minute job timeout; locally the session took 4–8 minutes.
  • Free-threaded builds on macOS and Windows.

Run the test suite on CPython 3.15t with nox (tests-3.15t) and add it
as an ubuntu-latest job to the test matrix. Free-threaded pythons are
listed separately in FREE_THREADED_PYTHONS, so that the type-safety
sessions and the mypy target versions only use SUPPORTED_PYTHONS.

Environment markers can't distinguish free-threaded builds, so the
tests session excludes test dependencies without free-threaded wheels
from the resolution with uv's --excludes:

- gcsfs imports grpcio, which has no cp315t wheels and is too slow to
  build, so the gcs tests are skipped. The docker_gcs fixture now skips
  without gcsfs, instead of failing test_mkdir_in_empty_bucket.
- hf-xet has no cp315t wheels and needs a recent Rust to build.
  huggingface_hub works without it and the hf tests still run.

PyNaCl (required by paramiko) has no cp315t wheels either, but builds
from source with its bundled libsodium. No extension module re-enables
the GIL during the test run.

Concurrent first lookups of a protocol without a UPath implementation
created a separate fallback class per thread, so paths created in
different threads couldn't be pickled and relative_to() rejected them.
All lookups now return the class registered in the _experimental
module.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant