fix(asap-tools): keep ProcessMonitor samples when a monitored process dies - #741
Merged
milindsrivastava1997 merged 3 commits intoSep 29, 2026
Conversation
… dies A monitored pid exiting mid-run crashed the sampler, so remote_monitor wrote no monitor_output.json and every pid's samples were lost. - Seed pid exits: roll back the partial round, mark the entry with exited_at_sample, and send the aligned data. - Child pid exits: stop sampling only that child. - remote_monitor stops the container client / timed wait early when the sampler reports an exit, and logs it when writing the output. - compare_costs skips flagged modes unless --allow_partial_runs. Closes #740 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
process_monitor depends on psutil, but CI installs only experiments/requirements.txt, so test_process_monitor failed to import. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ses-all-samples-when-one-monitored-process-dies
milindsrivastava1997
deleted the
740-processmonitor-loses-all-samples-when-one-monitored-process-dies
branch
September 29, 2026 02:30
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.
Closes #740
Problem
If any monitored process exited mid-run,
psutil.NoSuchProcessescaped the sampler loop, the sampler never sent its data, andremote_monitor.pyskipped writingmonitor_output.json— losing samples for every process. The run also continued unnoticed (the query client swallows per-query errors and runs its full schedule).Changes
process_monitor.pyexited_at_sample: Non the dead pid's entry, and send the data.remote_monitor.pycontrol_pipe.poll(0)and stops the client early when the sampler reports an exit.timedmode:time.sleep→control_pipe.poll(time_to_run)so it also ends early.monitor_output.json.start(), so it doesn't stop early, but data is now preserved.compare_costs.py: modes with a flagged pid are skipped with an error;--allow_partial_runsincludes them with a warning.constants.PROCESS_MONITOR_EXITED_AT_SAMPLE_KEY(per-pid field, so existing consumers that iterate keys as pids are unaffected).Testing
tests/test_process_monitor.py: seed death (real processes; checks alignment, rollback, and flag) and child death (mocked; monitor keeps sampling). Both fail on the previous code.pytest testsinasap-tools/experiments: 18 passed.🤖 Generated with Claude Code