Repository navigation
sminos: bench_scale.py stops what it started on SIGTERM or SIGINT (#152) - #423
Merged
Merged
Conversation
A SIGTERM (a timeout, a harness stopping it) killed bench_scale.py at once, skipping the finally that ends its processes, so its `sleep` sessions, its `daemon run` (and that daemon's uplink) and its stand-in kept running. A handler for SIGTERM and SIGINT now raises SystemExit(128 + the signal) into the existing finally blocks; a later signal is ignored so the cleanup it started is never cut short again. Each two-step cleanup is nested, so one interrupted step never skips the next, and the build itself ends the sessions it started when it is cut short. The sessions no longer hold the caller's stdout open. test_scale.py's BenchStops starts a small `run` in each mode, signals it mid-warm-up, and finds none of its descendants left and the synthetic machine removed (SIGTERM on DX2 and RL10, SIGINT on RL10). sminos 1.27.1. Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
… its own end Review of the first cut found three windows. `tick` and `profile` run the daemon's tick_all in the bench's process, which takes a SystemExit as one project's failure, so the stop was swallowed there; a signal between a child's start and its registration left that child unknown; and a first signal during the ordinary end cut that end short. The stop is now `Stopped`, a BaseException that is neither SystemExit nor KeyboardInterrupt. Every child goes through `spawn`, which notes a signal that lands while it starts the child and raises it only once the child is in STARTED. Main's end runs shielded (a signal is only noted there) and kills whatever of STARTED an unwind left running before it removes the synthetic machine, then exits 128 + the signal. The nested cleanups of the first cut are gone: the end's sweep covers what they guarded. test_scale.py adds a SIGTERM mid-tick in process (it fails with a SystemExit-based stop) and a signal inside spawn, and every stop test now checks the exit status is 128 + the signal. Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
The re-review found the `subprocess.run` children (a tick, the probe, `daemon status`, the verbs, `ps`) outside the registry: a signal between such a child's start and run's own handler left it unknown to the end's sweep. They now go through `run_child`, which starts the child with `spawn` and kills it if this process is stopped while it waits. The spawn test covers both ways in. Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
sminos/tests/bench_scale.pynow stops every process it started when it gets SIGTERM or SIGINT, in every mode: thesleepsessions,daemon run(its uplink ends with it), the hub or endpoint stand-in, and every waited-for child (a tick, the probe,daemon status, the verbs). It removes the synthetic machine unless--keepand exits 128 + the signal. B2's step 2 (bench_scale.py run --rl10on the mini) can now be timed out or interrupted without leaving load behind on a shared Mac.How
Stopped, aBaseExceptionthat is neitherSystemExitnorKeyboardInterrupt.tickandprofilerun the daemon'stick_allin the bench's own process, andtick_allcatches(Exception, SystemExit)per project, so aSystemExitthere was swallowed as one project's failure.spawn(orrun_child, for one it waits for). If a signal lands whilespawnis starting a child, it is only noted, and raised once the child is inSTARTED.main's end is shielded: from its first statement a signal is only noted. It kills whatever inSTARTEDan unwind left running, then removes the machine. A second signal does nothing; the cleanup already under way finishes./dev/null, so they no longer hold the caller's pipe open.Tests
test_scale.py'sBenchStops(runs in thesminosgate):--rl10, and SIGINT on--rl10. Each test records the bench's descendants before signalling, then checks that none is left after the exit, that the exit status is 128 + the signal, and that the synthetic machine is gone. Against the old script these tests found the sessions,daemon run, its uplink and the stand-in still running.tickin process. This one fails against aSystemExit-based stop.spawnorrun_childstarts a child: the child is registered, and the sweep ends it.Normal runs of
run(DX2 and--rl10),tickandverbswere checked by hand at small scale: same output and exit status, nothing left behind.Review
doperpowers:reviewer-medium ran three rounds.
tick_allswallowed the stop; a signal at a child's start left that child unregistered; a first signal during the ordinary end cut the end short. All three are fixed by the design above.subprocess.runchildren unregistered. Fixed withrun_child. It also reported a window at the very entry ofmain'sfinally, before the shield is set. That window exists only under a tracer: CPython runs no signal handler between entering afinallyand its first store. Dismissed.Residue (not fixed)
bench_open.uptime(), whichopenscalls for its summaries, startsuptimethrough a plainsubprocess.run. A signal landing inside that call'sPopencould leave oneuptimeunregistered, butuptimeexits on its own within milliseconds, so nothing is orphaned.daemon runstill gets up to 60 s to stop after a signal (its tick in hand, then its uplink's grace), as on the ordinary path. A harness that SIGKILLs sooner can still leave it behind.sminos 1.27.1.
Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)