Incorrect job counting
Opened this issue · 2 comments
MVKozlov commented
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
@MVKozlov Is this one fixed with one of the previous PRs? I'm trying to play cleanup on old issues.
MVKozlov commented
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