Skip to content

run_smoke: cap each script and kill its process group on expiry - #89

Merged
Jammy2211 merged 1 commit into
mainfrom
claude/backport-per-script-timeout-r3w1sv
Aug 23, 2026
Merged

run_smoke: cap each script and kill its process group on expiry#89
Jammy2211 merged 1 commit into
mainfrom
claude/backport-per-script-timeout-r3w1sv

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Leg A of the per-script timeout backport. Depends on PyAutoHands#257, which adds the kill_group helper this imports — merge that first (the import is guarded, so an older Hands falls back rather than breaking the gate, but the shared implementation only arrives once #257 lands).

The defect

This runner called subprocess.run(capture_output=True) with no timeout at all. When a script leaves a grandchild holding the inherited stdout pipe, the parent blocks on that pipe forever — even though the script's own work finished and the direct child exited. The gate then sits until the 6-hour GitHub Actions ceiling, reporting nothing since the last completed script. That is autolens_workspace_test#196, and this copy had the same shape.

Reproduced, against this exact file

A two-script suite whose second script spawns a grandchild and exits, with BUILD_SCRIPT_TIMEOUT=4:

Result
Before printed ::group::hangs.py and nothing further; still hung when the harness killed it at 30s. The cap was ignored because there was none.
After [TIMEOUT (4s)] hangs.py — 4.0s, exit 1, zero surviving grandchildren.

What it adopts

The implementation autolens_workspace_test already runs:

  • per-script cap via timeout_for(env), so a profile's BUILD_SCRIPT_TIMEOUT override is resolved parent-side where the kill timer lives;
  • the child in its own session, so the whole group is killed;
  • exit 124 rather than the signal — a timeout means "raise the cap or SLOW-skip it", which -9 would mislabel as an ordinary failure.

timeout_for and kill_group are imported from PyAutoHands build_util, each with a local fallback for a checkout without Hands on PYTHONPATH, so the PR gate and the mega-run share one implementation. The fallback path was verified against a stub build_util exposing timeout_for but no kill_group: still reports TIMEOUT, still zero survivors.

The pre-existing docstring wording in this file is left alone — tidying it is not this PR's job.


Generated by Claude Code

This runner called subprocess.run(capture_output=True) with no timeout at
all. When a script leaves a grandchild holding the inherited stdout pipe,
the parent blocks on that pipe forever — even though the script's own work
finished and the direct child exited. The gate then sits until the 6-hour
GitHub Actions ceiling, reporting nothing since the last completed script.
That is autolens_workspace_test#196, and this copy had the same shape.

Reproduced against this exact file: a two-script suite where the second
spawns a grandchild and exits. With BUILD_SCRIPT_TIMEOUT=4 the old runner
printed "::group::hangs.py" and then nothing, and was still hung when the
harness killed it at 30s — the cap was ignored entirely because there was
none. The new one reports "[TIMEOUT (4s)] hangs.py — 4.0s" at 4.0s, exits
1, and leaves zero surviving grandchildren.

Adopts the implementation autolens_workspace_test already runs:
per-script cap via timeout_for(env) so a profile's BUILD_SCRIPT_TIMEOUT
override is resolved parent-side where the kill timer lives, the child in
its own session so the whole group is killed, and exit 124 rather than the
signal — a timeout means "raise the cap or SLOW-skip it", which -9 would
mislabel as an ordinary failure.

timeout_for and kill_group are imported from PyAutoHands build_util, each
with a local fallback for a checkout without Hands on PYTHONPATH, so the
PR gate and the mega-run share one implementation.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GTPM1RmMvSuMvJkEntAMv8
@Jammy2211
Jammy2211 merged commit c4b1a20 into main Aug 23, 2026
3 checks passed
@Jammy2211
Jammy2211 deleted the claude/backport-per-script-timeout-r3w1sv branch August 25, 2026 18:58
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