Empty Pipe runs One job instead of Zero
fjf2002 opened this issue · comments
Do you want to request a feature or report a bug?
In my opinion this is a bug, cf.
@() | foreach { 1 }
What is the current behavior?
Start-RSJob runs one job.
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem
@() | Start-RSJob { 1 } | wait-rsjob | Receive-RSJob
... outputs "1" ...
What is the expected behavior?
... instead of nothing.
Which versions of Powershell and which OS are affected by this issue? Did this work in previous versions of our scripts?
Powershell 5.1, Windows Server 2016
Please provide a code example showing the issue, if applicable:
@() | Start-RSJob { 1 } | wait-rsjob | Receive-RSJob
I think this is not a bug, because Foreach-Object
can't work without pipeline at all but Start-RSJob
can
Well, I insist that Start-RSJob
"does the wrong thing" on an empty pipeline. Each time I use Start-RSJob
on a pipeline, I need boilerplate code to catch this edge case.
so, may be you have a method to determine if there is empty pipeline or no pipeline?
If so that can be implemented
Yep, and you could call the method foreach-rsparallel or something like that.
Nevertheless Start-RSJob on its own would still "do the wrong thing" on an empty pipeline. I consider that a bug.
The problem is, Start-RSJob currently tries to solve two partially contradicting tasks, i.e.
- Starting one job with no input and
- Starting a number of jobs that work on the pipeline.
so, where the code example ? ;-)