semantic tests: stop POSIX worker helpers when a test times out #2201

Open
github-bot wants to merge 1 commit from github-bot/gh-2201 into main AGit
Owner

@⁠EdenBendheim on GitHub · 2026-11-26 05:27 UTC · original
EdenBendheim:ubiq/semantic-posix-child-timeout → main · +54 −3 · 2 files · 1 commits · open

Claimed in the coordination issue as: SEMANTIC-RUNNER-POSIX-CHILD-TIMEOUT (claim)

On POSIX, a timed-out test could leave a helper holding its output pipes open. The parallel runner killed the worker and then waited for the helper to close the pipe. A 0.3-second timeout in a synthetic fixture returned after 3.13 seconds.

Timed workers now get their own process group. The timeout handler stops that group so pipe collection can finish. Untimed workers keep the caller's process group. Helpers that explicitly detach from the timed group are outside the cleanup boundary.

Depends on: #2073, #2114 (textual conflicts at the worker launch sites). All three changes can be implemented independently. The second PR to land will need to reconcile the launch arguments. Simulated merges with #2071 and #2135 were clean.

Three synthetic timeout cases reproduced the failure on main a73a57e13, including a worker that had already exited. With the fix, the parallel 0.3-second probe completed in about 0.35 seconds. All 28 runner tests passed on macOS, including checks for untimed serial and parallel worker process groups. Compile, diff and changed-file game-data checks passed.

GPUs tested: n/a. All tests used synthetic inputs.

AI-assisted: yes. Created with gpt-6.2-astra in Codex.

**@⁠EdenBendheim** on GitHub · 2026-11-26 05:27 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2201) `EdenBendheim:ubiq/semantic-posix-child-timeout` → `main` · +54 −3 · 2 files · 1 commits · open Claimed in the coordination issue as: SEMANTIC-RUNNER-POSIX-CHILD-TIMEOUT ([claim](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608)) On POSIX, a timed-out test could leave a helper holding its output pipes open. The parallel runner killed the worker and then waited for the helper to close the pipe. A 0.3-second timeout in a synthetic fixture returned after 3.13 seconds. Timed workers now get their own process group. The timeout handler stops that group so pipe collection can finish. Untimed workers keep the caller's process group. Helpers that explicitly detach from the timed group are outside the cleanup boundary. Depends on: #2073, #2114 (textual conflicts at the worker launch sites). All three changes can be implemented independently. The second PR to land will need to reconcile the launch arguments. Simulated merges with #2071 and #2135 were clean. Three synthetic timeout cases reproduced the failure on main `a73a57e13`, including a worker that had already exited. With the fix, the parallel 0.3-second probe completed in about 0.35 seconds. All 28 runner tests passed on macOS, including checks for untimed serial and parallel worker process groups. Compile, diff and changed-file game-data checks passed. GPUs tested: n/a. All tests used synthetic inputs. AI-assisted: yes. Created with gpt-6.2-astra in Codex.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:22:07 +00:00
Author
Owner

@⁠lixonik on GitHub · 2026-11-26 06:13 UTC · original · reviewed

Both new POSIX tests passed on Ubuntu 22.04 under WSL. I checked one remaining pipe-lifetime case separately. AI-assisted.

**@⁠lixonik** on GitHub · 2026-11-26 06:13 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2201#pullrequestreview-6069345015) · **reviewed** Both new POSIX tests passed on Ubuntu 22.04 under WSL. I checked one remaining pipe-lifetime case separately. AI-assisted.
@ -68,0 +81,4 @@
# A launcher can exit while a helper still owns a copy of its output pipe. The session's group ID is
# the original worker PID even after the launcher exits.
try:
os.killpg(proc.pid, signal.SIGKILL)
Author
Owner

@⁠lixonik on GitHub · 2026-11-26 06:13 UTC · original

[P3] Bound the pipe drain after sending the group kill. A helper that deliberately starts its own session can inherit the worker's stdout and stderr. The helper is outside the stated kill scope, but the second, unbounded proc.communicate() still waits for its pipes. A synthetic parallel worker with a detached helper that sleeps 2.5 s took 2.66 s to return for --timeout 0.5. A long-lived helper can hold the runner open indefinitely. Could the timeout path give the pipes a bounded drain without terminating the detached helper?

**@⁠lixonik** on GitHub · 2026-11-26 06:13 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2201#discussion_r4704534160) [P3] Bound the pipe drain after sending the group kill. A helper that deliberately starts its own session can inherit the worker's stdout and stderr. The helper is outside the stated kill scope, but the second, unbounded `proc.communicate()` still waits for its pipes. A synthetic parallel worker with a detached helper that sleeps 2.5 s took 2.66 s to return for `--timeout 0.5`. A long-lived helper can hold the runner open indefinitely. Could the timeout path give the pipes a bounded drain without terminating the detached helper?
Author
Owner

@⁠Tauwni on GitHub · 2026-11-26 09:25 UTC · original

Tested db8d971c9 on an Apple M3 (macOS 26.5.1, Python 3.15, Homebrew), against main a73a57e13. Synthetic inputs only.

  • tests/test_run_semantic_tests.py: 28/28 pass on this head (26/26 on main).
  • Reproduction with a throwaway suite of two files. One is test_hang.py, which starts python -c "time.sleep(3)" with Popen and then sleeps 60 s. The other is a passing test. Command: scripts/run_semantic_tests.py -j 2 --timeout 0.3 <dir>.
exit wall time
main 1 3.11 s (waits for the helper's pipe)
this PR 1 0.36 s

So on macOS too, the timeout now returns at the timeout instead of when the helper exits.

AI-assisted (Claude Code). No game data.

**@⁠Tauwni** on GitHub · 2026-11-26 09:25 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2201#issuecomment-7187976588) Tested `db8d971c9` on an Apple M3 (macOS 26.5.1, Python 3.15, Homebrew), against `main` `a73a57e13`. Synthetic inputs only. - `tests/test_run_semantic_tests.py`: 28/28 pass on this head (26/26 on `main`). - Reproduction with a throwaway suite of two files. One is `test_hang.py`, which starts `python -c "time.sleep(3)"` with `Popen` and then sleeps 60 s. The other is a passing test. Command: `scripts/run_semantic_tests.py -j 2 --timeout 0.3 <dir>`. | | exit | wall time | |---|---|---| | `main` | 1 | 3.11 s (waits for the helper's pipe) | | this PR | 1 | 0.36 s | So on macOS too, the timeout now returns at the timeout instead of when the helper exits. AI-assisted (Claude Code). No game data.
Author
Owner

@⁠DeadlyChirp on GitHub · 2026-11-26 10:50 UTC · original

Tested on Windows 11, Python 3.12.10, with this PR merged onto current upstream main.

  • tests/test_run_semantic_tests.py: 25 passed, 3 skipped, 33 subtests passed. The 2 new tests skip on Windows as intended ("POSIX worker process groups"); nothing else changed on this platform (main: 25 passed, 1 skipped).

(AI-assisted test run; output checked by hand.)

**@⁠DeadlyChirp** on GitHub · 2026-11-26 10:50 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2201#issuecomment-7189906937) Tested on Windows 11, Python 3.12.10, with this PR merged onto current upstream main. - `tests/test_run_semantic_tests.py`: 25 passed, 3 skipped, 33 subtests passed. The 2 new tests skip on Windows as intended ("POSIX worker process groups"); nothing else changed on this platform (main: 25 passed, 1 skipped). (AI-assisted test run; output checked by hand.)
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2201/head:github-bot/gh-2201'
git switch 'github-bot/gh-2201'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2201'
git switch 'github-bot/gh-2201'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2201'
git switch 'github-bot/gh-2201'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2201'
git switch 'main'
git merge --squash 'github-bot/gh-2201'
git switch 'main'
git merge --ff-only 'github-bot/gh-2201'
git switch 'main'
git merge 'github-bot/gh-2201'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.