Repository navigation
loop: drain on request (SIGUSR1) - #703
Merged
Merged
Conversation
A running loop sent SIGUSR1 submits no further psf, intake, reference or difference job (the cut at each submission, the rest of a pass under way included), keeps submitting the packet job of every difference that publishes, reruns a dead difference or packet job and no other, and exits 2 (1 with a failed or refused job) once nothing of the run is pending and no packet job is left to submit, its last stderr line the drain and the counts left. Every pass from the signal reports "draining": true and "left" by stage; a pass never asked is unchanged. --once, --stage and --dry-run take no drain; SIGTERM and SIGINT are untouched. The loop's help, the module texts, README and AGENTS no longer say that a pass produces packet sets to the topic (untrue since #680). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # AGENTS.md
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 and why
A running
rapidpipe loopcan now be asked to take nothing more in and finish what it has, by SIGUSR1. Runs 298 and 306 were stopped by stopping the loop's unit: the differences in flight ran on and published, and the 999 of run 306 got no packet job because the loop that would have submitted them was gone. A drain instead carries every difference already submitted through its packet job.The contract, each line with a test in
tests/unit/test_loop.py:test_a_pass_never_asked_to_drain_returns_what_it_returns_without_the_questioncompares the JSON of a pass with and without the question, byte for byte.run_passasksdraining()before each submission and each rerun.test_a_drain_asked_between_two_submissions_starts_no_later_one_but_the_packets: the request arrives after the first intake; the second intake and the reference never start, and the packet still goes. A pass asked before it plans submits its packets under the cap, and the other stages are not counted against it (test_a_draining_pass_submits_the_packets_whatever_the_other_stages_would_take_of_the_cap). From the request on, every pass carries"draining": trueandleftby stage:intakethe stems not taken in,psfandreferencethe jobs planned and withheld,differencethose withheld plus the deferred ones (test_a_draining_pass_counts_the_deferred_differences_as_left_and_submits_none). A pass before the request carries neither key.test_a_loop_sent_sigusr1_carries_a_difference_publishing_passes_later_to_its_packet_and_exits, five passes through the real CLI and a realos.kill). A dead difference or packet job is still rerun. A dead psf, intake or reference job is not rerun and is reported failed (test_a_draining_pass_reruns_a_dead_difference_or_packet_and_leaves_a_dead_intake_failed).drained. The loop then exits 2 (ExitCode.INCOMPLETE), or 1 if a job of the run failed or was refused, as now. Its last stderr line israpidpipe loop: run N drained on request; left unsubmitted: A stems not taken in, B psf, C reference and D difference jobs. Code 2 is the existing "not yet terminal" code, which the loop did not use until now;job waitandreprocessuse it for a timeout. It says that the selection is not finished and that the loop, started again, takes it up. No new code is added toExitCode; its docstring now names the loop's use.--localincluded).--once,--stageand--dry-runinstall none, so they are unchanged. SIGTERM and SIGINT are never touched. A second SIGUSR1 sets the same flag again (test_once_stage_and_dry_run_take_no_drain_and_no_loop_touches_sigterm_or_sigint; the CLI test sends the signal twice).--localis covered bytest_a_local_loop_sent_sigusr1_mid_job_runs_the_passs_packet_and_nothing_else.cli/main.py's module text andfoundation/loop.py's module text each describe the drain in one paragraph. None of them says any longer that a pass produces packet sets to the topic, which has been untrue since publish: a set's messages are keyed by the set, the send waits half an hour, and the loop does not sweep #680 (test_the_loops_help_describes_the_drain_and_no_send).Files
rapidpipe/foundation/loop.py:run_pass(..., draining=), the module's drain paragraph, and the "ends by producing" sentence removed.rapidpipe/cli/main.py: the SIGUSR1 handler (athreading.Event), the exit and stderr line, the parser description and the module text.rapidpipe/exitcodes.py:INCOMPLETE's docstring names the loop's drain.README.md,AGENTS.md: the stale "ends each pass withpublish" / "ending at the topic" corrected, and the drain named.tests/unit/test_loop.py: nine tests (twelve cases) and the docstring's contracts.Divergences
exitcodes.pyasks for the rapid_docs tool page to change first for a new value, and 2 already means "not yet terminal, come back". The tool page's table and loop.md's table carry it (loop: the drain on request (SIGUSR1); no page says the loop sends rapid_docs#259).Measurements
tests/unit/test_loop.pytests/uniton rapid-rusholmetest_measured_with_a_set_falls_back_to_it_on_any_measurement_error(both cases),OSError: [Errno 16] Device or resource busyon an.nfs*file under the EFSTMPDIR. This is the host's shared filesystem, not this change; CI is the gate.A mutation check: with the handler's install removed, the CLI test's
os.killends the pytest process (SIGUSR1's default action), so the test cannot pass without the handler.The baseline's loop findings (kepler-baseline, run 310)
Read from that card's RESULT, ledger,
loop-310.log(118 passes),guard-310.logandcounts-310.log. None is a loop defect, and none was fixed here:--dates 2026-09-28..2026-10-27planned exactly the window: 4,045 differences, every row dated 10-03 to 10-27, as in run 298. The loop drained and exited 1 on its 10 coverage-floor references and 211bkgestdifferences. This bears on the exit: a drain with failures exits 1, as in run 310.systemctl --user stopof the loop unit, the stop that stranded run 306's 999 packets. A drain is the stop such a guard should send, with--kill-whom=main.left.difference.rerunempty in all 118), and no Batch retry held.Improvements seen
--intervallater. That is harmless, and nothing was built for it.Session notes
tests/uniton this host's EFSTMPDIRfailstest_measured_with_a_set_falls_back_…on a busy.nfs*file, twice in two runs.What the next task must know
execthe loop so that--kill-whom=mainreaches it. The exit is 2 with no failed job, and the last stderr line has the shape above.Left
🤖 Generated with Claude Code