Skip to content

ci: test the free-threaded Python 3.14 build - #361

Open
pavlosambur wants to merge 2 commits into
pytest-dev:masterfrom
pavlosambur:ci/free-threaded-python-314
Open

ci: test the free-threaded Python 3.14 build#361
pavlosambur wants to merge 2 commits into
pytest-dev:masterfrom
pavlosambur:ci/free-threaded-python-314

Conversation

@pavlosambur

@pavlosambur pavlosambur commented Sep 5, 2026

Copy link
Copy Markdown

Free threading is officially supported as of Python 3.14 (PEP 779), but the
free-threaded build is not exercised anywhere in CI right now.

This matters more here than for a typical pure-Python package. Under xdist the
master runs a ServerStatusDB that workers connect to over a socket
(src/pytest_rerunfailures.py L597-605); the server itself runs in a background
thread (L785-786) and spawns a thread per worker connection (L795-797), with
shared state guarded by _suite_lock (L686). That is real concurrency, and it
has never been run without the GIL.

Changes:

  • a py314t-pytest91-xdist tox environment
  • a free-threading:py-3.14t:pytest-9.1 CI job, structured as a copy of the
    existing xdist job — that one also installs dependencies with pip rather
    than going through tox, so this mirrors the existing convention
  • the job asserts sys._is_gil_enabled() is false after importing pytest,
    xdist and the plugin, so it fails loudly instead of silently testing an
    interpreter that quietly re-enabled the GIL

Verified locally on a real GIL-disabled interpreter (Py_GIL_DISABLED=1,
sys._is_gil_enabled() returns False): tox -e py314t-pytest91-xdist gives
201 passed. tox -e linting is green.

Deliberately left out: the Free Threading trove classifier. Advertising
support in the same PR that starts testing it felt premature — happy to send
that separately once this job has been green for a while.

Unrelated, noticed while working on this: allow-prereleases: true in the
existing 3.14 jobs is now a no-op, since 3.14 is marked stable in
actions/python-versions. Happy to clean that up in a follow-up if useful.

Worked on this with Claude as an assistant; the reasoning above is mine
and I ran everything locally.

pavlosambur and others added 2 commits September 5, 2026 18:00
Free threading is officially supported since Python 3.14 (PEP 779), but the
free-threaded build was not exercised anywhere. Under xdist this plugin runs
a socket server in the master to coordinate reruns across workers, spawning a
thread per worker connection and sharing StatusDB behind a lock, so it is
worth running the suite without the GIL.

Add a py314t tox environment and a matching CI job. The job asserts that the
GIL is still disabled after importing the test dependencies, since importing
an extension that does not declare free-threading support re-enables it and
would leave the job silently testing nothing.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@pavlosambur

Copy link
Copy Markdown
Author

CI here needs maintainer approval since this is my first PR to this repo. In the meantime I ran the same workflow on my fork, on the same commit as this PR: https://github.com/pavlosambur/pytest-rerunfailures/actions/runs/33974552487

All 30 jobs pass, including the new free-threading:py-3.14t:pytest-9.1 one — 201 passed on Python 3.14.7 free-threaded, with the GIL verified disabled after importing pytest, xdist and the plugin.

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