Skip to content

Add -StreamTimeoutMs to Invoke-PkProcessBatch and Invoke-PkProcessDispatch - #74

Merged
HalRiveria-Bot merged 3 commits into
mainfrom
feat/stream-timeout
Nov 19, 2026
Merged

HalRiveria-Bot merged 3 commits into
mainfrom
feat/stream-timeout

Conversation

@HalRiveria-Bot

Copy link
Copy Markdown
Collaborator

What was wrong

How long the batch and the dispatcher wait for a program's output after it exits, when something it started holds the output open, was fixed at 15 seconds. The batch never had a way to change it. Since #71 moved that wait into the dispatcher's default -JobPollCompleted, a -JobFinalize that passed a shorter -StreamTimeoutMs to Complete-PkProcess no longer shortened it: the job held its slot for the full 15 seconds first.

What changed

  • Invoke-PkProcessBatch and Invoke-PkProcessDispatch take -StreamTimeoutMs (default 15000, 0 or more, a negative value refused before anything starts). The default poll gives up on held output after it, and the batch passes it to the dispatcher.
  • The default poll records the limit on the job as OutputWaitMs, a new reserved job key, when its wait starts. Complete-PkProcess with no -StreamTimeoutMs of its own uses that instead of 15000, so it doesn't wait a second time. One given its own still waits only the rest, as before. OutputWaitMs is only read together with the poll's OutputWait stopwatch, so a field of that name on a job the dispatcher never waited on is ignored.
  • The default poll is a .GetNewClosure() block now, to carry the limit. Measured on stub jobs with 20,000 jobs, it's no slower: 5.0-5.5 s on 5.1 against 5.0-6.1 s before, and about 2.6 s on 7 either way.
  • Help text and README updated: the parameters, the reserved keys, and the -JobFinalize note.

How it was tested

  • New harness section BD, 7 assertions. With an 8 s held output:
    • Batch at 1000 ms: given up on at 1.1-1.2 s, with the output so far.
    • Batch at 0: 0.1 s.
    • Dispatcher at 1000 with a plain Complete-PkProcess: 1.0-1.1 s.
    • Dispatcher at 1000 with -StreamTimeoutMs 3000 in finalize: 3.0-3.1 s.
    • A re-queued job, timed out again: 2.1 s for both runs.
    • A batch inside a runspace worker: 1.1-1.2 s.
    • -1 refused by both.
  • On the old code, 5 FAILED, 574 passed, on both runtimes. The parameter didn't exist. The re-queue and worker assertions were added after that run.
  • On this branch, the full harness passed on 5.1 and then 7: 581 assertions each.

🤖 Generated with Claude Code

HalRiveria and others added 3 commits November 19, 2026 01:23
…patch

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…the shared default

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HalRiveria-Bot
HalRiveria-Bot merged commit 9f33bdb into main Nov 19, 2026
2 checks passed
@HalRiveria-Bot
HalRiveria-Bot deleted the feat/stream-timeout branch November 19, 2026 06:47
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.

2 participants