Provides an alternative to PSjobs with greater performance and less overhead to run commands in the background, freeing up the console and allowing throttling on the jobs.
MIT License
541
stars
87
forks
source link
Support for `Receive-RSJob -Wait -AutoRemoveJob` #187
Feature Request: Support for -Wait and -AutoRemoveJob in Receive-RSJob (as done in the built-in Receive-Job).
What is the current behavior?
Without this implemented, one must separate processing and cleanup, like so
1..10 | Start-RSJob {
"I am $($_)"
} | Wait-RSJob | Receive-RSJob
Get-RSJob | Remove-RSJob -Force
If it were implemented, it would allow for single-pipe processing and (I presume) lessen the memory load when a large number of objects are piped in.
1..10 | Start-RSJob {
"I am $($_)"
} | Wait-RSJob | Receive-RSJob -AutoRemoveJob
For the project I am currently working on, I created a function to emulate this behavior (and -Wait, as in the builtin Receive-Job), but I'm sure it would be faster if implemented in PoshRSJob.
function Receive-CompletedJobs {
param([switch]$AutoRemoveJob, [switch]$Wait, [int]$WhileGT = 0, [uint32]$SleepMS = 500)
do
{
$jobs = @(Get-RSJob)
$done_jobs = @($jobs | where {$_.Completed})
foreach ($job in $done_jobs)
{
$job | Receive-RSJob -ea Continue -WarningAction Continue -InformationAction Continue
if ($AutoRemoveJob) { $job | Remove-RSJob -Force }
}
if (-not $Wait) {
break
}
elseif ($jobs.Count - $done_jobs.Count -gt $WhileGT) {
sleep -Milliseconds $SleepMS
}
else {
break
}
} while ($Wait)
}
Do you want to request a feature or report a bug?
Feature Request: Support for
-Wait
and-AutoRemoveJob
inReceive-RSJob
(as done in the built-inReceive-Job
).What is the current behavior?
Without this implemented, one must separate processing and cleanup, like so
If it were implemented, it would allow for single-pipe processing and (I presume) lessen the memory load when a large number of objects are piped in.
For the project I am currently working on, I created a function to emulate this behavior (and
-Wait
, as in the builtinReceive-Job
), but I'm sure it would be faster if implemented in PoshRSJob.