Skip to content

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

Open
EdenBendheim wants to merge 1 commit into
ProjectLeonida:mainfrom
EdenBendheim:ubiq/semantic-posix-child-timeout
Open

EdenBendheim wants to merge 1 commit into
ProjectLeonida:mainfrom
EdenBendheim:ubiq/semantic-posix-child-timeout

Conversation

@EdenBendheim

Copy link
Copy Markdown
Contributor

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.

@lixonik lixonik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

# 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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[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?

@Tauwni

Tauwni commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

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.

@DeadlyChirp

Copy link
Copy Markdown

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.)

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.

4 participants