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: make Chocolatey multiple instance friendly #1579
Comments
this looks somehow similar to #1258 Idea 1: lock execution of choco.exe via a global mutex: although "blocking" choco.exe to run until another, currently running instance exists would be possible in theory I don't like the idea of a choco.exe that's doing a long running install (such as VS2017) blocking all other choco calls. Idea 2: lock |
For anyone interested in choco being multiple instance friendly... I've created this helper until such time: It's currently PRE-release. I have a little more work to do. Feedback welcome. |
Just an update: 0.0.2-pre .nupkg is available on my GitHub repository:
Better explanation of 0.0.2 from the config
|
I think this should be enabled by default / "invert" the switch - so the default behavior doesn't change (make it an explicit choice). Additionaly (sorry - I haven't checked your code yet) - does your code check whether the "already executing |
I would have to disagree. Doing so would neuter the extension and it might as well not be installed. It's major purpose is to prevent problems, not just warn. Warnings do nothing for me unless I'm watching upgrades (generally I watch INSTALLS), I don't sit around and watch upgrades - they're automated: https://chocolatey.org/packages/choco-upgrade-all-at. It makes more sense to me to have it take action (i.e. wait for problems to go away and then continue) then to do nothing. Anyone who would want the warning only feature could just configure it that way.
Yes. In Get-chocoStatus, which calls Get-chocoCounts
|
@bcurran3 - I don't think we're getting anywhere concerning the warning/hard-stop topic ... but I get your point. From my point of view Consider following scenario: My suggestion: recursively check if the executing i.e. check
Futhermore, I wouldn't suggest a hard name check on the choco shims & executables .. it'd be way more stable if you check all open handles in the chocolatey /bin directory. (I tend to use sysinternals "listdlls" for such tasks.)
Hope that helps / lets you understand the "reach" of such a change in the default behavior of choco.exe. |
I'm not understanding you on the suggested scenario. We can move this to Gitter/e-mail/Issue on my GitHub/wherever if we're too much of a "distraction" here. So that I can try to understand the "dynamic" scenario: I'm all for making it better. If you want to add to it, please do! PR's welcome.
There is no changing of any behavior of choco.exe. There's changing of install/uninstall scripts "behavior." Do me a favor though: Install, test, and look at the methodology and flow. (If you have, thanks! If not yet, please do.) Keep in mind also that this extension is 100% opt in. There is no scenario where it would be used as a dependency. |
I wrote a new function that support Self-Serve and probably the central management (didn't test it yet ...) function isUniqueChocoInstance( ) {
$currentParentProcess=Get-Process -Id (Get-CimInstance -Class Win32_Process -Filter "ProcessID=$($PID)").ParentProcessId
$chocoCommand='chocolatey', 'choco', 'cinst', 'clist', 'cpack', 'cpush', 'cup', 'cuninst', 'cver', 'chocolatey-management-service'
$isSelfServe=$False
if ($currentParentProcess.ProcessName -eq 'chocolatey-agent'){
$isSelfServe=$True
Write-verbose "Running in SelfServe"
}
Write-verbose "Searching for Choco.exe process"
$count=0
Get-Process -ea silentlycontinue -Name choco| ForEach-Object {
$_ParentName=$(Get-Process -Id (Get-CimInstance -Class Win32_Process -Filter "ProcessID=$($_.Id)").ParentProcessId).ProcessName
if ($_.Id -eq $PID -or $_.Id -eq $currentParentProcess.Id){
Write-verbose "$($_.Id) same process or parent of the current"
} elseif ($_ParentName -eq 'chocolatey-agent'){
Write-Verbose "$($_.Id) is choco in background mode"
} elseif ($chocoCommand.contains($_ParentName)) {
Write-Verbose "$($_.Id) is choco"
$count+=1
} else {
Write-Verbose "$($_.Id) is probably a shim of choco"
}
}
Write-Verbose "count is $count"
if ($isSelfServe){
$count-=1
}
if ($count -gt 0) {
return $False
}
return $True
}
if (isUniqueChocoInstance) {
Write-Warning "Is Unique"
} else {
Write-Warning "Not unique"
} |
RE: https://groups.google.com/forum/#!topic/chocolatey/GRJrv99RwK8
What You Are Seeing?
Attempting to run multiple concurrent instances of choco.exe can cause choco to become "confused."
In the past when I've attempted to run Chocolatey commands in two different administrative consoles on the same computer, I've bumped into problems. Not always, but often. Depends on what I'm trying to do. Not certain, but pretty sure it's always a Chocolatey licensed edition (I run Pro) package synchronization related issue. Though I encounter this issue specifically due to the licensed edition package synchronization feature, I believe this request would benefit Chocolatey globally in all editions.
What is Expected?
For choco.exe to check for another instance of itself and pause so no unexpected/unwanted behavior occurs. choco.exe could display a message such as "Pausing, another instance of choco.exe is running." or "Pausing, waiting for another instance of choco.exe to finish." then loop until the other instance is finished. A default timeout such as 5 minutes could be built in or a new configurable feature created and used to abort.
How Did You Get This To Happen? (Steps to Reproduce)
Here's a real world test done 5 minutes ago:
I opened up two Command Prompts with administrative rights. I arranged them so I could easily see them and access them fast. I typed "cinst atom" in one and "cinst git" in the other. I hit enter on both within a half second of each other. Both start installing. Atom finishes first while git takes longer being a meta package and having to download more packages. Atom finishes. While git.install is still installing, I attempt a "choco uninstall atom," subsequently many warnings ensue.
The text was updated successfully, but these errors were encountered: