proxb / PoshRSJob

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.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

  1. Starting one job with no input and
  2. Starting a number of jobs that work on the pipeline.

so, where the code example ? ;-)