-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Add RunspaceID handling to Start-RSJob for better throttling support #75
Comments
I think I was looking at this at one point in my initial module build but ended up shelving it for one reason or another. This is something that I will definitely revisit and see about adding in a future release. |
After some thinking, I realize that this feature will look better if it will be implemented as |
That makes sense to me. I'll explore this probably in the coming weeks once I get a couple of other things knocked that I am working on. |
I think what I will do is automatically generate a Batch name (as a guid or something like that) if one is not given and link that to the runspacepool and if the user decides to use a batch name, then that will be used to create the runspacepoolID as well. I'll need to update the DLL file to make the runspacepoolid a string as opposed to a guid. |
Good - lets runspaceID will be equal to batch name.
Not just create, but add new job to existing runspace with the same name/id |
Assuming the existing runspacepool hasn't been disposed of by that time, in which case a new runspacepool would be created. This reminds me that I should look at adjusting the current time before a runspacepool is disposed of. Currently it is after a minute of inactivity but I may bump it to 5 minutes with this addition. |
Made some progress on this with the linking of Batch to RunspacePoolID and most of my testing showed that this was working great. The only thing holding me back now is providing some extra code for those who use $_ within the script under a ForEach (or similiar) loop which currently only works when piping directly to the function. I'm probably going to have to some sort of scriptblock inspection to see if the variable exists outside of any other loop and treat it as though it came from the pipeline. 1..5|ForEach {
Start-RSJob -ScriptBlock {$_}
} |
I may have been overthinking my last comment example. The example you showed works great and I am just leave it at that although I did find a way to detect if the function is part of a ForEach command loop... I might test that just a bit and if it doesn't work like I want it to then I will scrap it and publish the current update that I have this weekend. |
@MVKozlov |
Thanks :) bonus: |
Cool! I'll get that added to my existing Pester tests. |
I'm leaving this open until I can add the Pester test. |
Pester test added to existing tests |
Reopening as this brought on a breaking change (#108). I am still looking to include this functionality but need to spend more time researching and testing to ensure it doesn't break core functionality of the module. |
I do not have Issues as in #108 (leave comment about it) |
@MVKozlov is your Pester test from August 15 supposed to pass on the "Full Pipe input", and fail on the "OneByOne Pipe input"? |
@AspenForester , my Pester test works as intendent (all pass) on post-1.6.1.0 and pre-1.7.2.9 or on my 1.7.2,9 fork - #109 |
for now
1..25 | Start-RSJob -throttle 5
can work as expectedand
1..25 | foreach { $_ | Start-RSJob -throttle 5 }
is notbecause latest creates it own RunspaceID for each new job
Will be better if Start-RSJob can have a possibility to add new job to already existing RunSpacePool
may be with
-AddToExistingRunspace
switch or-RunspacePoolID
parameterthat will need existing pool checking instead of
$RunspacePoolID = [guid]::NewGuid().ToString() [....]
i.e. invoke
new RunspacePool
code only if selected with-RunspaceID
parameter is not foundThe text was updated successfully, but these errors were encountered: