Skip to content

CI: add pytest-timeout so a wedged test fails fast (#368)#369

Open
matthewholman wants to merge 2 commits into
mainfrom
issue/368/pytest-timeout
Open

CI: add pytest-timeout so a wedged test fails fast (#368)#369
matthewholman wants to merge 2 commits into
mainfrom
issue/368/pytest-timeout

Conversation

@matthewholman

Copy link
Copy Markdown
Collaborator

Closes #368.

Adds pytest-timeout (dev dep) and a 300s per-test cap in [tool.pytest.ini_options] (timeout_method="thread", compatible with pytest-xdist and all platforms), so a test that wedges on a network/ephemeris fetch fails fast with a traceback instead of hanging the CI job for hours (observed on ubuntu-3.14 and ubuntu-3.13 across recent PRs).

Verified locally: pytest reads the config (timeout: 300.0s / method: thread) and enforcement fires (a 5s sleep fails at ~1s under --timeout=1).

A random matrix leg's pytest step has repeatedly hung for hours on a network/
ephemeris fetch with no timeout, requiring a manual cancel + re-run (seen on
ubuntu-3.14 and ubuntu-3.13 across recent PRs). Add pytest-timeout (dev dep) and
a 300s per-test cap in [tool.pytest.ini_options] (timeout_method='thread', which
works with pytest-xdist and on all platforms). A wedged test now fails fast with
a traceback pointing at the hang instead of stalling the whole job.

Verified: pytest reads the config (header shows 'timeout: 300.0s / method:
thread') and enforcement fires (a 5s sleep fails at ~1s under --timeout=1).

Closes #368.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@matthewholman matthewholman added this to the v1.0 milestone Jun 29, 2026
The first revision set timeout_method='thread', which on timeout calls os._exit()
and so kills the whole pytest-xdist worker -- CI surfaced this as ten 'worker gwN
crashed' errors during a transient ephemeris/NAIF outage (every affected test was
an ephem-fetch one). The 'signal' method (SIGALRM) instead raises a clean per-test
'Failed: Timeout' and lets the worker continue. Verified clean under -n 2.

CI runs only on Linux/macOS, where SIGALRM is available.

Refs #368.
@matthewholman matthewholman requested a review from kjnapier June 29, 2026 19:51
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.

CI: add a pytest timeout so a wedged test fails fast instead of hanging for hours

1 participant