Skip to content

ci: only install pytest-freethreaded for the free-threaded test run - #548

Merged
kylebarron merged 2 commits into
kylebarron:mainfrom
ump45nose:ci/freethreaded-group
Oct 28, 2026
Merged

kylebarron merged 2 commits into
kylebarron:mainfrom
ump45nose:ci/freethreaded-group

Conversation

@ump45nose

Copy link
Copy Markdown
Contributor

Closes #528.

pytest-freethreaded takes over pytest_runtest_call as soon as it is installed and runs each test 200 times on 10 threads, whether or not the GIL is disabled. Because it was a default dev dependency on Python >= 3.13, the 3.13 and 3.14 jobs (and any local run on 3.13+) looped every test, and a BaseException (pyo3 PanicException, or pytest's own Failed/Skipped) could hang the run, as described in the issue.

This takes option 2 from the issue:

  • move pytest-freethreaded out of the default dev dependencies into a new freethreaded dependency group (keeping the python_version >= '3.13' marker)
  • request that group only in the 3.14t step: uv run --python 3.14t --group freethreaded pytest tests --require-gil-disabled
  • relock uv.lock (only the group entries change; locked with uv 0.12 so the lockfile stays at revision = 3, and uv lock --check with uv 0.8.24, the version CI pins, is clean)

I went with the dependency group instead of addopts = --threads 1 --iterations 1 because those flags would be rejected on 3.11/3.12, where the plugin isn't installed.

Local developers who want the stress run can use uv run --group freethreaded pytest tests --require-gil-disabled on a free-threaded interpreter. Since uv run doesn't uninstall extra packages, an existing local .venv keeps the plugin until uv sync (or uv pip uninstall pytest-freethreaded).

Testing

  • Python 3.13, after building core/compute/io with maturin dev: the plugin is no longer installed by default; pytest tests gives 207 passed in ~2 s. A throwaway test that appends a line to a file per call ran 1 time by default and 201 times with --group freethreaded.
  • Python 3.14t: uv run --python 3.14t --group freethreaded pytest tests --require-gil-disabled gives 207 passed (plugin active).

AI disclosure: I made this change with help from an AI coding assistant (Grok Bot), which wrote the edits and the PR text. I reviewed the diff and ran the checks above locally.

pytest-freethreaded hooks every test as soon as it is installed and runs
it 200 times on 10 threads, whether or not the GIL is disabled. It was a
default dev dependency on Python >= 3.13, so the 3.13 and 3.14 CI jobs
and every local run on 3.13+ looped each test, and a BaseException such
as a pyo3 PanicException or pytest's own Failed/Skipped could hang the
run instead of failing it.

Move it into a `freethreaded` dependency group and only request that
group in the 3.14t `--require-gil-disabled` step.

Closes kylebarron#528
@github-actions github-actions Bot added the ci label Oct 24, 2026
@ump45nose

Copy link
Copy Markdown
Contributor Author

CI failure on the Python 3.13 job looks unrelated to this PR: mkdocs/mkdocstrings cannot load DuckDB's intersphinx inventory (https://duckdb.org/docs/current/clients/python/reference/objects.inv → HTTP 404). Happy to rebase once that inventory URL is fixed upstream.

(AI-assisted reply.)

@ump45nose

Copy link
Copy Markdown
Contributor Author

CI note: pytest is green; the red Python job is mkdocs build --strict failing because the DuckDB objects.inv URL 404s (https://duckdb.org/docs/current/clients/python/reference/objects.inv). Same as on #549 — not caused by the freethreaded pytest install change here.

@kylebarron kylebarron left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅

@kylebarron
kylebarron merged commit b5bec35 into kylebarron:main Oct 28, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pytest-freethreaded runs every test 200 times on 10 threads in all 3.13+ jobs

2 participants