Closed MVKozlov closed 7 years ago
hmm... Everything is much worse than I thought even in v1.7.2.4
import-module poshrsjob
1..3|start-rsjob { start-sleep -sec 15; $_ }
take 45 sec to exit to prompt
while measure-command { 1..3|start-rsjob { start-sleep -sec 15; $_ } }
or $jobs = 1..3 | start-rsjob { $_ }
takes milliseconds to run, get-rsjob
or $jobs
right after that take 15 sec to display job list
sorry, have no time to check earlier versions today :(
I really need to figure out and fix the issue with AppVeyor that broke my V2 tests. I think I saw a PR over at @RamblingCookieMonster Invoke-Parallel (https://github.com/RamblingCookieMonster/Invoke-Parallel/pull/41) that I might steal from to get it working again.
In the meantime, it looks like some background stuff that uses reflection for the Types may not be V2 compatible (https://github.com/proxb/PoshRSJob/blob/master/PoshRSJob/TypeData/PoshRSJob.Types.ps1xml). I'll have to test more in V2 and figure out the best way to handle that. I don't really want to lose this functionality due to V2 as it provides better state tracking of RSJobs.
Just did another test v2 with 1..3|start-rsjob { start-sleep -sec 15; $_ }
seems that delay exists when job object outputs it's values to host
If I do
$j = 1..3 | Start-RSJob { start-sleep -sec 15; $_ }
start-sleep -sec 14
$j
delay while outputting jobs from $j
does not appear, so it's really .Types related.
but disappearing the State
's for v2 is the real problem because of suspended Wait-RSJob
I found the issue with the disappearing states which was due to one of the techniques that I use for reflection was missing some of the other parameters that exists in V3+. Luckily it was a simple fix by adding $Null as the second parameter and it supports V2+.
Before
PowerShell $CRP = $_CRP.GetValue($Worker)
After
PowerShell $CRP = $_CRP.GetValue($Worker,$Null)
I couldn't reproduce the delay either after making that change so this may solve both items. I'll add this to the list of things when I upload the next version tonight or tomorrow.
Another v2 error (I continue to report here)
ConvertScriptBlockV2 does not support $v -is [type]
syntax
PS D:\> $a = 1; $a -is [array]
False
PS D:\> $a | Start-RSJob { $_ -is [array] }
Create : Exception calling "Create" with "1" argument(s): "You must provide a value expression on the right-hand side o
f the '-is' operator."
At PoshRSJob\Private\ConvertScriptBlockV2.ps1:88 char:26
debug show that scriptblock converted to Param($_)$_ -is array
workaround: $_ -is "array"
start-sleep issue not fixed, but I fix all other in my fork latest commit
About Start-Sleep
inside scriptblock on PSv2
Seems I found a fix
--- a/PoshRSJob/TypeData/PoshRSJob.Types.ps1xml
+++ b/PoshRSJob/TypeData/PoshRSJob.Types.ps1xml
@@ -83,7 +83,7 @@
$this.innerjob.HadErrors
}
Else {
- ($this.innerjob.Streams.Error -ne $null)
+ ($this.innerjob.Streams.Error.Count -ne 0)
}
</GetScriptBlock>
</ScriptProperty>
let it be here until widely tested
Jobs can't set it's state on powershell v2
What is the expected behavior?
actually Jobs a running but it's State not set, so Wait-RSJob does not exit