Skip to content

Releases

v4.3

Choose a tag to compare

@HalRiveria HalRiveria released this 04 Dec 00:03
f875ad1

With this, I consider the kit stable and ready for deployment. All reviews between 4.2 and 4.3 only turned up uncommon to extremely rare edge cases, so I expect this will be the final update unless a user-reported issue comes in. Cheers!

ParallelKit 4.3

After updating, start a new PowerShell window. The kit's compiled parts changed, so a session that loaded an older copy will refuse to load this one.

A fix release. Killing a program's tree (a time limit, an abort's force-stop, a failed start, -KillTreeOnExit) now says when it may have left something running, instead of reporting a clean stop. An abort requested from code or a callback stops new work straight away. Two inputs that used to be mangled without a word are now errors: an argument with a NUL character, and a runspace job with two keys that differ only in case. A list of arguments for a drive-relative cmd.exe path is quoted for cmd.exe. Programs and working folders past Windows' path limit start by their 8.3 short names, and -WorkerScript ${function:Name} works. -MaxOutputChars no longer drops a surrogate pair that fits.

Fixed

  • A list of arguments is quoted for cmd.exe under a drive-relative path too. Given -FilePath 'C:cmd.exe' (or C:cmd), the kit quoted a list the ordinary way instead of the way cmd.exe reads it, so an element holding a quote and & could make cmd.exe run a second command. Full and bare paths (cmd.exe, C:\Windows\System32\cmd.exe) were already quoted for cmd.exe. (#113)
  • An abort requested from code or a callback stops new work straight away. An abort requested between the engines' own checks, by Request-PkAbort before a run or from a callback (-ResultHandler, -NextJobProvider, -PollCallback, -JobFinalize), let the run start one more round of workers or programs, or ask -GroupProvider for more groups, before it stopped. The engines now check for an abort before each start and before asking for more work, so an abort from a -JobStarter, or a Ctrl+C while the dispatcher is starting programs, starts nothing more either, and one from -GroupProvider, -JobBuilder, -GroupCompleteCallback or -GroupReleaseCheck asks for no more groups. A job a -NextJobProvider returns from the same call that requests the abort still runs. (#114, #121, #128)
  • A failed start no longer leaves behind what the program started, if the program had already exited. When a program's output readers couldn't start (4.2 stops the program then), or a custom -JobStarter threw after starting its program, the kit stopped the program, but a program that had already exited was passed over, along with anything it had started. That's now ended too, through the program's own Job Object. (#115)
  • -WorkerScript ${function:Name} works. Given a function's own scriptblock, Invoke-PkRunspaceBatch didn't see its parameters, so a job with values was refused ("doesn't declare it"), a declared $CancelToken wasn't filled in, and mandatory parameters weren't checked up front. The worker-safety check also flagged a $script: at the function's top level, which is fine there, as in a { } block. Both function f { param(...) } and function f(...) now work. (#117)
  • An argument with a NUL character is an error instead of being cut off. Windows reads a command line up to its first NUL, so the argument was cut short there and every argument after it was dropped, without a word. Now it's an error before the program starts, in a list or a string, for any program (in a batch, that command's StartError). (#119)
  • -KillTreeOnExit no longer says a program it killed "has no Job Object of its own". With -KillTreeOnExit, a program the kit killed for its time limit (the dispatcher's, the batch's or Invoke-PkProcessWithTimeout's) or in an abort's force-stop got that warning, though nothing was wrong: the kill had already ended what the program started. (#122)
  • A case-sensitive job's canceltoken reaches the worker. Invoke-PkRunspaceBatch put its own token in place of a canceltoken key from a case-sensitive hashtable ([hashtable]::new()). A job with two keys that differ only in case, such as Id and id, is now refused with a message naming them, rather than the worker silently getting only the later one. (#126)
  • -MaxOutputChars keeps an emoji or other surrogate pair that fits. Output exactly as long as the cap lost a pair that fell where the kept start ends: a😀b under a cap of 4 came back as ab, with 2 characters counted as dropped. (#127)
  • A failed start says when what its program started may still be running. When a program's output readers couldn't start, or a -JobStarter threw after starting its program, the kit said the program was stopped even when Windows wouldn't end the program's own Job Object, or an exited program had none, so what it started could still be running. The failure now says so. (#131)
  • A time limit or force-stop warns when it may have left something running. When a killed program had no Job Object of its own (Windows refused one, or NoJob), or Windows wouldn't end it, the kill went to taskkill /T, which misses a child whose parent has already exited, without a word. That's now warned about once per session (a failed start that had to kill such a program says so in its error), and Invoke-PkProcessWithTimeout's time-limit error says when the program couldn't be killed rather than that it was. (#133, #134)

Changed

  • -KillTreeOnExit warns when Windows won't end what a program left running. It ends a program's leftovers through the program's own Job Object. If Windows refused to end that Job Object, nothing said so, and the leftovers kept running (showing only as a stream timeout if they held the program's output). It now warns, once per session, naming the process. They still end when PowerShell does. (#116)
  • A program or working folder whose path is too long for Windows starts by its 8.3 short name. Windows won't start a program by a path of 260 characters or more, or in a working folder of 259 or more, even with long paths enabled, so these starts failed ("The filename or extension is too long", "The directory name is invalid"). The kit now tries once more with their short names (C:\PROGRA~1\...). That works where the drive makes short names, usually the system drive; elsewhere the start fails with Windows' error as before, now followed by a sentence saying the path's length is why. (#125)

Documentation

  • The command reference's ConvertTo-PkArgumentString row names cmd.exe among the programs a list is quoted for, as the Arguments section already did. (#120)
  • The Arguments section says what cmd.exe's delayed expansion does to a quoted argument. With it on, !NAME! is expanded inside quotes, a ^ in an argument that holds a ! is dropped, and in a batch file an unset !NAME! or a lone ! is dropped too; the kit's quoting can't stop that, as with %NAME%. (#130)

v4.2

Choose a tag to compare

@HalRiveria HalRiveria released this 02 Dec 19:48
a504e3a

ParallelKit 4.2

After updating, start a new PowerShell window. The kit's compiled parts changed, so a session that loaded an older copy will refuse to load this one.

A fix for a program the kit could lose track of, and a warning where -KillTreeOnExit used to do nothing silently. 4.2 is also the first version on the PowerShell Gallery since 4.0: 4.1 was released on GitHub only.

Fixed

  • A program whose output readers can't start is stopped, and its start reported as failed. Once a program was running, the kit started a thread to read each of its output streams. If one of those threads couldn't start (Windows out of resources, say), the program kept running with nothing reading its output and nothing holding on to it: the batch and the dispatcher never saw it. Now the program and anything it started are stopped, and the command gets a StartError like any other failed start. (#111)

Changed

  • -KillTreeOnExit warns when it can't reach a program's tree. It works through the Job Object the kit gives each program it starts. For a program without one (Windows refused it, the kit is running without Job Objects, or a custom -JobStarter started the program itself), it used to do nothing, silently. It now warns, once per session. StartMode CreatedInJob describes how programs are started, not whether each one got its own Job Object. (#111)

Documentation

  • "Choosing limits" says that each running program takes two threads, one reading each of its output streams, so hundreds of programs at once mean hundreds of threads. (#111)

v4.1

Choose a tag to compare

@HalRiveria HalRiveria released this 02 Dec 17:23
ea911a5

The release file was lost due to an outage at the time of release, however 4.2 was pushed shortly after so I won't be redoing the 4.1 release.

ParallelKit 4.1

A small release: the dispatcher now warns when -GroupProvider outputs more than one value in a call, which is almost always a stray value or a list returned without its leading comma. The kit's compiled parts didn't change, so a session that has 4.0 loaded can load 4.1 without a new window.

Added

  • The dispatcher warns when -GroupProvider outputs more than one value in one call. A stray value (an ArrayList.Add index, say) or a list returned without the leading comma is still taken as part of one group, as before, but now with a warning once per run that says how many values arrived. Discard a stray value with $null = ..., and return a list group as return ,$list. (#105)

Documentation

  • Limits now says what a locked-down machine sees when the kit loads. On Windows PowerShell 5.1 the compile writes a few temporary files to %TEMP% and deletes them during the load, and with no logging policy set, PowerShell records every load as a Warning-level script block logging event (4104), on 5.1 and 7. (#110)

v4.0

Choose a tag to compare

@HalRiveria HalRiveria released this 02 Dec 04:41
94aa349

ParallelKit 4.0

After updating, start a new PowerShell window. The kit's compiled parts changed, so a session that loaded an older copy will refuse to load this one.

The kit can now be built as a PowerShell module, imported with Import-Module in place of dot-sourcing the file. Before that, 4.0 settles its names: Invoke-PkRunspaceJobs is now Invoke-PkRunspaceBatch, the batch and dispatch engines all take -MaxConcurrent and -AbortTimeoutSeconds, and parameters kept only for old scripts are gone. A batch now works when the kit's functions aren't global, and the worker-safety check catches more scriptblocks handed to .NET. Several of these changes can break an existing script, so read "Upgrading" first.

Upgrading from 3.5

  • Set-PkMessageHandler throws in worker code. The handler a worker set was its own runspace's scriptblock, which the main thread then ran, and that can hang or crash. Set it on the main thread before starting the workers; Write-PkMessage in a worker already goes to it. (#95)
  • Invoke-PkProcessWithTimeout throws instead of starting its program while an abort or cancel is in force. A quick program used to run anyway. A cleanup program that has to run then needs -IgnoreAbort: in -JobAbortCleanup, say, or after an aborted Invoke-PkRun, since an abort stays in force until Reset-PkAbortState. (#96)
  • Invoke-PkRunspaceBatch refuses a worker that passes a wrapped scriptblock to a .NET method or constructor: in parentheses, cast to [scriptblock], or with .GetNewClosure(), in the call or through a variable. .NET turns it into a delegate, which can hang or crash a worker. Put # pk:ignore on the line if the method really takes a scriptblock. (#97)
  • Invoke-PkRunspaceJobs is now Invoke-PkRunspaceBatch. Nothing else about it changes but the two parameter names below. The old name is gone. (#98)
  • -MaxConcurrent and -AbortTimeoutSeconds are the only names for the limits. On Invoke-PkProcessBatch, Invoke-PkProcessDispatch and Invoke-PkRunspaceBatch, replace -MaxParallel with -MaxConcurrent, and -DrainTimeoutSeconds with -AbortTimeoutSeconds. (#98)
  • Initialize-ParallelKit has no -MaxConcurrentProcesses and no ThreadPool in its result. Both have done nothing since 3.4. Take the parameter off your call; don't check the field. (#99)
  • The dispatcher's -AbortPollCallback is gone. Use -PollCallback, its name since 3.0. (#99)

Fixed

  • Invoke-PkProcessBatch works when the kit's functions aren't global. Loaded for one module only, every batch failed with "'Complete-PkProcess' is not recognized". A .GetNewClosure() callback of your own still needs the functions it calls to be global. (#94)
  • Invoke-PkProcessWithTimeout no longer starts a program during an abort or cancel. A quick one ran to the end, and a slower one for about 200 ms before it was killed. (#96)
  • The DelegateCast check sees a scriptblock through parentheses, a [scriptblock] cast or .GetNewClosure(). [System.Threading.Tasks.Task]::Run({ 1 }.GetNewClosure()) in a worker wasn't flagged. (#97)
  • Loading the kit over a newer version's compiled parts says so. The message said an "older version" was loaded; it's "a different version" now. (#99)

Added

  • The kit as a PowerShell module, on the PowerShell Gallery: Install-Module ParallelKit -Scope CurrentUser. It's the same code as ParallelKit.ps1, imported with Import-Module in place of dot-sourcing, and Build/New-ParallelKitModule.ps1 builds it from a copy of the repository. The README's new "As a module" section says how it differs: a refused import doesn't stop your script by itself, and a module of yours that uses the kit lists it in RequiredModules or imports it with -Global. The module's version has three parts: Get-Module shows this release as 4.0.0. (#100, #102, #103)

v3.5

Choose a tag to compare

@HalRiveria HalRiveria released this 01 Dec 01:56
a402e15

ParallelKit 3.5

After updating, start a new PowerShell window. The kit's compiled parts changed, so a session that loaded an older copy will refuse to load this one.

Programs the kit starts now get an empty stdin instead of PowerShell's own, so one that reads its input can't take what was meant for your script or wait for it forever; -InheritStdin gives the old behavior back. -KillTreeOnExit is new: it kills whatever a program left running when it exits. And a worker that reads a variable it never declares, such as one a .GetNewClosure() captured, is refused with a message instead of reading it as empty. The stdin and worker changes can affect an existing script, so read "Upgrading" first.

Upgrading from 3.4

  • Programs no longer inherit PowerShell's stdin; theirs is empty. A program that reads its input gets the end of it at once, instead of taking input meant for your script or waiting for it. If a program needs the input your script was given, use -InheritStdin (new in this release). timeout.exe refuses to run with empty input ("Input redirection is not supported"), so cmd /c timeout /t 5 as a delay fails at once now: use ping -n 6 127.0.0.1 >nul instead. -InheritStdin brings timeout.exe back only if your script's own stdin is a console. (#86)
  • The batch and the dispatcher's default starter read an InheritStdin key on each command or job: $true or $false. Don't use that name for a field of your own; another value there is a failed start. (#86)
  • The dispatcher uses one more key on each job, KillTree, and it and the batch read a KillTreeOnExit key: $true or $false. Don't use those names for fields of your own; another value of KillTreeOnExit is a failed start. (#87)
  • Invoke-PkRunspaceJobs refuses a worker that reads a variable it never declares or assigns. Such a variable (one of your script's, or one a .GetNewClosure() captured) read as empty in the worker, with no error. Pass it as a job value instead. If something the worker runs sets it (a helper file it dot-sources, a module it imports), put # pk:ignore on the line that reads it. $global: names, drive-qualified ones ($env:) and shared functions aren't checked. (#89)

Fixed

  • A program that reads its input no longer takes your script's, or hangs waiting for it. With a script run as type list.txt | powershell -File script.ps1, a program the kit started could read from that list; one that waited for input sat until its time limit, or forever without one. (#86)
  • Invoke-PkRunspaceJobs starts faster on Windows PowerShell 5.1 when its worker calls functions from installed modules (Get-FileHash, say). The check it makes first searched all of PSModulePath on every call; now each module is looked up once per session. With 154 modules installed, a one-job run went from 47 ms to 23 ms. A module the kit didn't find, and that you then install, is only seen in a new window. (#88)
  • A worker made with .GetNewClosure() no longer loses its variables without a word. { param($Id) "[$prefix$Id]" }.GetNewClosure() returned [1] in a worker, whatever $prefix was. The run is now refused, and the message says to pass the variable as a job value. (#89)
  • The README says which programs get a batch file's %*, or a list passed through cmd.exe /c, back wrong: ones built against the old msvcrt.dll runtime, as most MinGW builds are, when an element holds a ". It also says that a program can't start a child outside the kit's Job Object. (#90, #91)

Added

  • -InheritStdin on Start-PkProcess, Invoke-PkProcessWithTimeout, Invoke-PkProcessBatch and Invoke-PkProcessDispatch: give programs PowerShell's own stdin, as before 3.5. A command's or job's own InheritStdin key, $true or $false, overrides it either way. (#86)
  • -KillTreeOnExit on Invoke-PkProcessWithTimeout, Invoke-PkProcessBatch and Invoke-PkProcessDispatch: when a program exits, kill whatever it started that's still running, so nothing it left behind can hold its output open until -StreamTimeoutMs. A command's or job's own KillTreeOnExit key, $true or $false, overrides it either way. Off by default, since some tools leave a build server or a daemon running on purpose. It needs the program to have a Job Object of its own, the normal case; one without is left alone. With your own -JobPollCompleted, the kill happens in Complete-PkProcess. (#87)
  • Test-PkWorkerSafety has a new finding, UndeclaredVariable, for the rule above. It names the variable and the line. (#89)

v3.4.1

Choose a tag to compare

@HalRiveria HalRiveria released this 24 Nov 01:57
a1f4ca6

ParallelKit 3.4.1

After updating, start a new PowerShell window. The kit's compiled parts changed, so a session that loaded an older copy will refuse to load this one.

A fix release: two cases where programs could run without cleanup if PowerShell was killed, and the kit said nothing, now warn. No parameters or result fields change.

Fixed

  • A Job Object that couldn't be set up is reported however the kit was started. A script that started programs without calling Initialize-ParallelKit or Invoke-PkRun first got no warning when Windows refused the kit a Job Object, though the README says it warns: its programs ran with no cleanup if PowerShell was killed. It now warns once, as Initialize-ParallelKit does. (#83)
  • A running program Windows won't add to the Job Object is reported. Where the kit starts a program and adds it to the Job Object just after (StartMode AddedToJob), a refusal was ignored, and that program ran on with no cleanup if PowerShell was killed. The kit now warns once, naming the process and why. A program that has already exited by then, which Windows also refuses, doesn't count. (#83)

v3.4

Choose a tag to compare

@HalRiveria HalRiveria released this 19 Nov 15:39
849907c

ParallelKit 3.4

After updating, start a new PowerShell window. The kit's compiled parts changed, so a session that loaded an older copy will refuse to load this one.

This release is about what happens when a program leaves something running that holds its output open. That no longer makes new programs lose their output, stalls the whole batch or dispatcher, or piles up output nobody can get in memory, and a kill now takes everything the program started, even a helper whose parent has already exited. Two new parameters: -StreamTimeoutMs on the batch and dispatcher sets how long to wait for held output, and -MaxOutputChars caps how much of a program's output is kept. The kit also leaves the thread pool's settings alone now, refuses runspace jobs that leave out a mandatory worker parameter before anything starts, and takes a code page given as a string. A few of these changes can affect existing scripts, so check "Upgrading from 3.3" before you update.

Upgrading from 3.3

  • A kill now takes everything the program started, including what it left running on its own. A time-limit kill, an abort's force-stop and Stop-PkProcessTree used to miss a program's descendant whose parent had already exited (a start /b helper, say); it ran on until PowerShell exited. If a program you run on a time limit deliberately launches something meant to outlive it, that now goes too. A program that exits on its own still leaves what it started running, as before. (#77)
  • The kit no longer raises the thread pool's minimum. Initialize-ParallelKit, the first program started and each Invoke-PkProcessDispatch used to raise it to at least 128 worker threads, a setting your own code shares; output reads have threads of their own since this release, so the kit doesn't need it. If your own code relied on that, raise it yourself with [System.Threading.ThreadPool]::SetMinThreads. Initialize-ParallelKit still returns ThreadPool (always $true) and still accepts -MaxConcurrentProcesses, which does nothing now. (#76)
  • Results have two more fields at the end, StdoutDroppedChars and StderrDroppedChars (0 unless -MaxOutputChars is set), on Complete-PkProcess, Invoke-PkProcessWithTimeout and each batch result. They show up as new columns in Format-Table, Export-Csv and JSON. (#75)
  • What a stream timeout hands over is that stream's text from then on. The read of a held stream still goes on until the program holding it lets go, but drops what it reads. So a second Complete-PkProcess on the same job returns the same text as the first, not what arrived since, and so does the read task's Result once the stream ends. (#70)
  • StreamError gives the failed read's own reason, not PowerShell's "Exception calling "WaitAll" ... One or more errors occurred" wrapper. A script that matched on that text needs to change. (#70)
  • With the dispatcher's default -JobPollCompleted, a job finishes once its output has been read, or 15 seconds after its program exited if something holds the output open, instead of as soon as the program exits. The job keeps its slot meanwhile. A -JobFinalize that passes Complete-PkProcess a shorter -StreamTimeoutMs, 0 included, no longer gets its result sooner: the wait has already happened, so set the dispatcher's own -StreamTimeoutMs instead (new in this release). A longer one still waits the rest. (#71, #74)
  • The dispatcher uses three more keys on each job, OutputWait, OutputWaitOver and OutputWaitMs. Don't use those names for fields of your own. (#71, #74)
  • Invoke-PkRunspaceJobs refuses a job that leaves out a mandatory worker parameter. A job missing a [Parameter(Mandatory)] parameter used to fail on its own and land in Errors while the rest ran. Now a fixed -JobParams list is refused before anything starts ("Nothing was started"), and a -NextJobProvider job stops the run when it arrives, as a key the worker doesn't declare already did. CancelToken is exempt, since it's filled in, and so are workers with parameter sets. (#72)

Added

  • -StreamTimeoutMs on Invoke-PkProcessBatch and Invoke-PkProcessDispatch: how long to wait for a program's output after it exits when something it started holds the output open (default 15000 ms, as before; 0 doesn't wait). In the dispatcher, a Complete-PkProcess in -JobFinalize with no -StreamTimeoutMs of its own uses it. (#74)
  • -MaxOutputChars on Start-PkProcess, Invoke-PkProcessWithTimeout, Invoke-PkProcessBatch and Invoke-PkProcessDispatch: keep at most that many characters of each output stream, so a program that prints gigabytes doesn't fill memory. Past the cap, the first half and the last half are kept, and the new result fields StdoutDroppedChars and StderrDroppedChars say how many characters were left out. The rest is still read, so the program never stalls on a full pipe. A command's or job's own MaxOutputChars key overrides it. The default, 0, keeps everything, as before. (#75)

Fixed

  • Programs left holding their output no longer make new programs lose theirs. Each output read used a thread-pool thread until its stream closed, so once leftover programs (from a cmd /c start /b ..., say) holding their output open had used up the pool's minimum (128 threads by default, two per program), a new program's output came back empty with StreamTimedOut, even a plain echo. Each read now has a thread of its own: a held stream costs one thread until the program holding it lets go, and other programs' output isn't held up. 3.2 and 3.3 both had this. (#69)
  • Output written after a stream timeout no longer piles up in memory. A program that kept writing to a held stream after the result was handed over had all of it kept, though nobody could get it: 60 MB written after the timeout took PowerShell's managed memory from about 9 MB to 127 MB until the writer let go. Now that output is read and dropped. (#70)
  • A read that fails while the other stream is held open is reported. The result used to show only StreamTimedOut, with StreamError empty and the failed stream $null for no visible reason. StreamError now has the reason in that case too. (#70)
  • A finished program's output pipes are closed when its output ends, rather than at the next garbage collection. (#70)
  • One program's held output no longer stalls the whole batch or dispatcher. The wait for it (up to 15 seconds) ran on the dispatch loop's own thread, so no other program was started, finished, killed at its time limit or stopped by an abort meanwhile: a program with a 2 second limit next to one whose output was held for 6 seconds was killed at 6 seconds. The wait now runs alongside the other jobs. After an abort's wait, a program that had already finished keeps the output that arrived, instead of being force-stopped and reported as aborted. (#71)
  • The text a stream timeout hands over never ends in half of a two-part character. With UTF-16 output (cmd /u, say), an emoji read half before the timeout used to come back as a lone first half; it's now left out. (#75)
  • A kill no longer leaves behind what the program started through a step that has already exited. Each program the kit starts now has a Job Object of its own, so a time-limit kill, an abort's force-stop and Stop-PkProcessTree end its whole tree at once, including a start /b helper whose parent is gone, which taskkill /T couldn't find. Such a helper used to keep running, and if it held the program's output, the job waited another 15 seconds after the kill: a command with a 2 second limit took 17 seconds. (#77)
  • -OutputEncoding takes a code page given as a string, such as '65001' read from a CSV or a config file, or as the Int64 ConvertFrom-Json gives on PowerShell 7. Both used to be refused with a message that said to use 65001. (#72)

v3.3

Choose a tag to compare

@HalRiveria HalRiveria released this 18 Nov 04:44
f72ea5c

ParallelKit 3.3

After updating, start a new PowerShell window. The kit's compiled parts changed, so a session that loaded an older copy will refuse to load this one.

This release fixes a dispatcher run that could go on forever, keeps output that a leftover program held open instead of losing it, and makes sure killing thousands of programs at once kills their children too. Time limits that can't work are now refused up front. It also adds a Duration field to process results, and Version and StartMode to Initialize-ParallelKit. A few of these changes can affect existing scripts, so check "Upgrading from 3.2" before you update.

Upgrading from 3.2

  • Time limits that can't work are refused up front. These now stop the call with an error naming the parameter:

    • -TimeoutSeconds of NaN or infinity on Invoke-PkProcessBatch and Invoke-PkProcessDispatch, which acted as no limit.
    • A negative -StreamTimeoutMs, Wait-PkProcess -TimeoutMs, -AbortTimeoutSeconds or -DrainTimeoutSeconds. -1 waited without limit; other negative values failed later or acted as 0.

    0 means what it did before. (#63)

  • -NextJobProvider goes by its last value. If a call's output ends in $null, the run ends, even when a job hashtable came before it (that job used to run). Of two job hashtables, the last one runs, as before, but the first is now warned about. (#62)

  • -GroupProvider output that ends in $null ends the groups, with a warning. That includes a list given as one group whose last item is $null, because it can't be told apart from a stray value followed by return $null. (#62)

  • A stream that timed out now has its text, not $null. A script that checked Stdout or Stderr for $null to spot a stream timeout should check StreamTimedOut instead. (#66)

  • Process results have a new Duration field, and Initialize-ParallelKit has Version and StartMode, so a Format-Table of either shows more columns. (#65, #67)

Fixed

  • A -GroupProvider that let a value out before return $null never finished. $log.Add('asked'); return $null reached the dispatcher as one more group, so it asked again forever. That output now ends the groups, with a warning. (#62)
  • Output held open by a leftover program is cut short, not lost. When a program started by your program (a compiler server, say) kept stdout or stderr open past the stream timeout, that stream came back empty, so a build step whose helper outlived it lost its whole log. Each stream now comes back with what arrived before the timeout, and StreamTimedOut still says it was cut short. (#66)
  • Killing thousands of programs at once could leave their children running. The tree kill passed every program to one taskkill call. Windows refuses that call past about 2,500-3,000 programs, and the fallback then killed only the programs themselves. It now uses as many taskkill calls as needed. A taskkill that hangs is now killed instead of being left running. (#64)
  • A -GroupReleaseCheck that let a value out could release a held group early. $log.Add($g); return $false was read as true. Only the check's last value counts now, as with -JobPollCompleted. (#62)

Added

  • Duration on process results: how long each program ran, from its start to its exit or kill, as a [TimeSpan]. It doesn't include time spent waiting for a slot, or waiting for its output afterwards. It's on Invoke-PkProcessBatch's results and on Invoke-PkProcessWithTimeout's and Complete-PkProcess's result, and it's $null for a command that never started. $batch.Results | Sort-Object Duration -Descending finds the slow ones. (#67)

  • Initialize-ParallelKit reports Version and StartMode. StartMode says how the kit starts programs in this session:

    • CreatedInJob: inside the Job Object, the normal case.
    • AddedToJob: started, then added to the Job Object just after.
    • NoJob: no cleanup if PowerShell is killed.

    The README's "Bugs and questions" now asks for Initialize-ParallelKit's output in an issue. (#65)

  • A warning when the kit can't create programs inside the Job Object. This relies on a private part of .NET. When it wasn't available, the kit silently fell back to starting the program and adding it to the Job Object just after, and a child the program starts in that moment can escape the cleanup. The kit now warns once when it falls back. It also falls back now when setting up a start fails, where 3.2 reported that the program couldn't start. (#65)

v3.2

Choose a tag to compare

@HalRiveria HalRiveria released this 17 Nov 15:31
d83c838

ParallelKit 3.2

After updating, start a new PowerShell window. The kit's compiled parts changed, so a session that loaded an older copy will refuse to load this one.

This release closes the last gap in "No orphans": a program the kit starts can no longer slip a child process past its Job Object. It has two small changes that can affect existing scripts. Check "Upgrading from 3.1" before you update.

Upgrading from 3.1

  • $job['Proc']'s own StandardOutput, StandardError and StartInfo are no longer set. Proc is still the program's Process, and HasExited, ExitCode, WaitForExit, Kill and Dispose work as before. Read output from StdoutTask and StderrTask, as the docs already say. (#56)
  • A start error has shorter text. It now gives Windows' reason, such as "The system cannot find the file specified", without PowerShell's Exception calling "Start" with "1" argument(s): wrapper. Anything that matches on the old text needs updating. The error itself, and Windows' error code inside it, are unchanged. (#56)

Fixed

  • A child process started straight away could survive the script being killed outright. The kit added each program to its Job Object just after starting it, so with cmd /c tool.exe, tool.exe could already be running outside it, and kept running if the script was killed from Task Manager. Each program is now created inside the Job Object, so everything it starts is killed with the script. Ctrl+C, aborts and timeouts were never affected. This removes the note about it under Limits. (#56)

v3.1

Choose a tag to compare

@HalRiveria HalRiveria released this 17 Nov 12:49
3f6909a

ParallelKit 3.1

After updating, start a new PowerShell window, so nothing from the older copy is left in your session.

This release fixes the dispatcher's force-stop and finalize steps, closes a quoting gap for cmd.exe itself, and has three changes that can affect existing scripts. Check "Upgrading from 3.0" before you update.

Upgrading from 3.0

  • cmd.exe given a list gets the same quoting as a .bat or .cmd program. When FilePath is cmd or cmd.exe (any folder) and Arguments is a list, a quote inside an element is now written "" instead of \", and an element with a line break is an error. Ordinary /c lists, with spaces, quotes or trailing backslashes, still reach the program after /c as given. (#51)
  • Only the last value a -JobPollCompleted outputs counts. If your poll writes its answer and then something else, put the answer last or send the rest to $null. (#49)
  • Invoke-PkProcessWithTimeout refuses a -TimeoutMs below 1. It used to start the program and kill it at once. (#50)

Security

  • A list in Arguments can no longer make cmd.exe run another command when the program is cmd.exe itself (FilePath = 'cmd.exe', Arguments = @('/d', '/c', 'tool.exe', $file)). 3.0 closed this for .bat and .cmd programs only, so an element holding a quote, such as an untrusted value like a" & del ... & ", could still end the quoting and run what followed. (#51)
  • A batch file that reads its argument as %~1 undoes the kit's quoting. %~1 strips the quotes, so a value like a & echo INJECTED runs as a command inside the batch file. That happens in your batch file, outside the kit's control: write "%~1" (or %1) there. The README now says so. (#45)

Fixed

  • Stopping about 20 or more running programs at once took 10 seconds and could leave some of their child processes running. This hit an abort's force-stop and the cleanup after an error. (#46)
  • A -JobFinalize that disposed its job's process and then threw left every other running job's child processes running. They're now killed, as when any other callback throws. (#47)
  • When -JobFinalize threw, -JobAbortCleanup was also called for the job it was finalizing, although that job had finished. A cleanup that deletes partial output could delete its real output. Now only jobs the kit kills or never starts get the cleanup. (#48)
  • A -JobPollCompleted that wrote a stray value before its answer (an ArrayList.Add index, say) made a running job look done, so it was finalized and its process disposed while the program still ran. (#49)

Documentation

  • A program with spaces in its path, run through cmd.exe /c, needs the one-string form. cmd.exe strips the quotes from it whatever the quoting, so give it '/d /s /c ""C:\My Tools\tool.exe" "a b""'. This isn't new in 3.1; the README now spells it out. (#51)
  • A program started in its parent's first moment (tool.exe under cmd /c tool.exe) can miss the kit's Job Object, and then survives the script being killed outright. It's rare, and Ctrl+C, aborts and timeouts aren't affected. See Limits in the README. (#52)
  • Invoke-PkRunspaceJobs' -Cts help now says the kit also cancels your source when it exits with workers still running (one of your callbacks threw, say), not only on an abort. (#53)