Repository navigation
Wait for a job's output alongside the other jobs, not on the dispatch loop's thread - #71
Merged
Merged
Conversation
…lize Complete-PkProcess's wait for the output (up to 15 s) ran inside the batch's -JobFinalize, on the dispatch loop's own thread, so while one program's output was held open no other job was polled, started, killed at its time limit or stopped by an abort. The dispatcher's default -JobPollCompleted, which the batch uses, now counts a job as done once its program has exited and both reads have ended, or 15 s after it saw the exit. The job keeps its slot meanwhile. Complete-PkProcess waits only what's left of that (OutputWait), and after an abort's wait the final pass sets OutputWaitOver, so a job whose program had finished takes the output that arrived instead of being force-stopped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After an abort's wait, a program that exited just before the final pass could still have its last output in flight. Complete-PkProcess now waits up to 250 ms then, instead of not at all. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 was wrong
The batch's
-JobFinalizecallsComplete-PkProcess, whose wait for the output (up to 15 s) ran on the dispatch loop's own thread. While one program's output was held open by something it started, no other job was polled, started, killed at its time limit or stopped by an abort. Two programs at-MaxConcurrent 2, one leaving a helper holding its output for 6 s, the other with a 2 s time limit: the limited one was killed at 6.2 s. A dispatcher whose-JobFinalizecallsComplete-PkProcessdid the same.What changed
-JobPollCompleted, which the batch uses, counts a job as done once its program has exited and both reads have ended, or 15 s after it saw the exit (Complete-PkProcess's default stream timeout). The job keeps its slot meanwhile, so the slot count still means jobs in flight, and the loop carries on with the other jobs.Complete-PkProcesswaits only what's left of that wait, timed by the poll's newOutputWaitkey. With the default it has nothing left to wait for.OutputWaitOveron the jobs still running. A job whose program has finished then takes the output that has arrived (StreamTimedOut), with at most a 250 ms wait, instead of being force-stopped and reported as aborted. A program still running is force-stopped as before.-StreamTimeoutMsin-JobFinalizestill does, and the batch's behavior while a program's output is held open.The time-limit
taskkill(Stop-PkTimedOutJob) still runs on the loop; it didn't fall out of this change.How it was tested
New harness section BB, on the batch and the dispatcher's default poll:
Complete-PkProcessin-JobFinalize);The helpers' pings carry
-w 4321, and the section kills only those.On the old code (main), the four new behaviors fail on both runtimes. Full harness on Windows PowerShell 5.1:
With this change, on both runtimes:
Full harness: Windows PowerShell 5.1
ALL PASSED (565 assertions), PowerShell 7ALL PASSED (565 assertions).🤖 Generated with Claude Code