Skip to content

Bound the backend pytest session so a wedged xdist worker cannot eat the job - #9530

Merged
danielhanchen merged 2 commits into
mainfrom
ci/bound-backend-pytest-session
Aug 22, 2026
Merged

danielhanchen merged 2 commits into
mainfrom
ci/bound-backend-pytest-session

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

The gap

studio-backend-ci.yml already passes --timeout=330, and its comment states the guarantee:

a test that never returns fails with its own name in the summary instead of taking the job's 45 minutes down with it and reporting "cancelled"

That guarantee did not hold. pytest-timeout arms inside each xdist worker, so it is never consulted when the controller is the thing stuck.

Evidence

On fix/appimage-colrv1-runtime-9453, (Python 3.13) reached 95% and then emitted nothing for 36.8 minutes until the 45m job cap cut it:

20:52:38  ........................................ [ 95%]
21:29:26  ##[error]The operation was canceled.

Three runs in a row, and job cleanup terminated three orphan python processes each time. Because a timed-out job reports cancelled, this is indistinguishable from ordinary concurrency supersession unless you diff the job duration against timeout-minutes.

For reference the same lane on main finishes in 11-12 minutes, so this is a hang, not slowness.

The change

Wrap the session in coreutils timeout: SIGINT at 1500s (roughly 3x the 8-10 minute norm, well inside the job's 45), SIGKILL 60s later.

Verification

Reproduced with a test that forks a child that never exits, under -n 2 --timeout=8:

result
unwrapped silent indefinitely, per-test cap never fires
wrapped exits 124 with a traceback through execnet/multi.py safe_terminate -> workerpool.waitall

That frame is the controller blocked on its workers, which is why the per-test cap could not help. The dump names a stuck frame, not always a test name, and the comment in the diff says so rather than overpromising.

…the job

--timeout=330 arms inside each xdist worker, so it never fires when the controller
is what is stuck. On the #9473 branch this step went silent at 95 percent for 36.8
minutes, three runs running, each burning the full 45 minute budget and reporting
cancelled, which reads exactly like ordinary concurrency supersession.

Wrap the session in coreutils timeout: SIGINT at 1500s so pytest dumps where it was
stuck, SIGKILL 60s later. Reproduced with a test that forks a child that never exits.
Unwrapped the run is silent forever and the per-test cap never fires. Wrapped it exits
124 through execnet safe_terminate -> workerpool.waitall, the controller blocked on
its workers.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 6221d3ed41

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: ce7f26258e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen merged commit 26c7da6 into main Aug 22, 2026
11 checks passed
@danielhanchen
danielhanchen deleted the ci/bound-backend-pytest-session branch August 22, 2026 23:11
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