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.
MIT License
541 stars 87 forks source link

Incorrect job counting #170

Open MVKozlov opened 6 years ago

MVKozlov commented 6 years ago

There is a bug based on #169

Code sample:

1 .. 2 | Foreach-Object {
  $_ | Start-RSJob {
     $_
     (10 * $_ + 1) .. (10 * $_ + 5) | Start-RSJob { $_ } | Wait-RSJob | Receive-RSJob
  }
}
Get-RSJob
Get-RSJob | Receive-RSJob

Currently Receive-RSJob returned correct result, but Get-RSJob return only 2 jobs

I expect that Get-RSJob should return 12 jobs

proxb commented 6 years ago

@MVKozlov Is this one fixed with one of the previous PRs? I'm trying to play cleanup on old issues.

MVKozlov commented 6 years ago

It seems this is not bug, but powershell-by-design feature. $global:variable defined inside start-rsjob {} block (i.e. inside child runspace) do not correlate with $global:variable in main runspace. It can be fixed by using synchronized hash, but I'm not sure if we should do this