Skip to content

Invoke-PkProcessBatch: add -TimeoutSeconds - #9

Merged
HalRiveria merged 3 commits into
mainfrom
feat/batch-timeout
Oct 28, 2026
Merged

HalRiveria merged 3 commits into
mainfrom
feat/batch-timeout

Conversation

@HalRiveria-Bot

Copy link
Copy Markdown
Collaborator

What was wrong. Invoke-PkProcessBatch had no per-program time limit: a program that hung held its slot until it exited or the run was aborted. The README's only workaround was to drop down to Invoke-PkProcessDispatch and write a -JobPollCompleted check by hand.

What changed. -TimeoutSeconds (default 0 = no limit) kills a program still running after that long, using the dispatcher's -JobPollCompleted and the stopwatch Start-PkProcess already returns. Every batch result gets a new TimedOut field, set in all three places a result is built. A timed-out program goes through -OnComplete like any other, and the rest of the batch carries on. A negative value is refused. README: the result field list, a paragraph on the option, and the Limits bullet now says only the dispatcher lacks a limit.

Testing. New assertions:

  • ping -n 30 in a batch with -TimeoutSeconds 2 is killed in about 2s and marked TimedOut, while a fast command in the same batch finishes normally.
  • The timed-out program still reaches -OnComplete.
  • A negative value is refused.
  • The every-field assertions now include TimedOut.

These fail against main (no such parameter or field). 183 assertions pass on 5.1.

🤖 Generated with Claude Code

HalRiveria and others added 3 commits October 28, 2026 03:22
A program that hung held its batch slot until it exited or the run was
aborted; the only way round it was dropping down to the dispatcher.
-TimeoutSeconds kills a program still running after that long. Its
result gets TimedOut = $true (a new field on every batch result) and
still goes through -OnComplete; the rest of the batch carries on.
0, the default, means no limit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eal kill

Killing only the program left any programs it started running and
holding its output open, so collecting its result waited the full 15s
stream timeout on the main thread. New Stop-PkProcessTree kills the
tree with taskkill /T, falling back to Process.Kill.

TimedOut was set before the kill, so a program that exited on its own
right at the deadline was reported as timed out. It's now set only if
the kill actually happened.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HalRiveria
HalRiveria merged commit 549b44f into main Oct 28, 2026
1 check passed
@HalRiveria
HalRiveria deleted the feat/batch-timeout branch October 28, 2026 07: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