Vishwanath S Manvi
Vishwanath S Manvi

Reputation: 29

How do I serialize msiexec.exe installation using multiprocessing or any other module via python scripting?

I have a automated jenkins job which runs msiexec.exe installation out of a python script . Multiple instances of the same script can be initiated with different parameters on the same machine. Since msiexec.exe can handle only 1 installation at a time, any parallel installation which starts throws an error and jenkins job hangs!

To avoid parallel installation i added a while loop to check if any msiexec task is running and wait while it is completed. But this still is not failproof as i see some race condition issues.

step that needs to be serialized:

subprocess.check_call('msiexec /a 'install.msi')

while loop already implemented:

while "msiexec.exe" in os.popen('tasklist /FI "IMAGENAME eq msiexec.exe"').read().strip():

I believe creating a process lock will yield better results than a a while loop on checking if the msiexec task has completed. Any ideas on how it can be achieved? Please note it has to be using stock modules part of python 2.7.3. Installing new modules is not a option.

Upvotes: 1

Views: 571

Answers (2)

Stein Åsmul
Stein Åsmul

Reputation: 42136

Task List Delay: More info about how MSI custom actions work behind the scenes - msiexec.exe will remain for 10 minutes in the task list after every deployment operation.


Mutex: msiexec.exe sets a mutex whilst running the InstallExecuteSequence of an MSI (What is a mutex?). This is to allow the installation to be rolled back if there is an error. Hence it is necessary to prevent changes from other MSI files - sort of like handling multiple-threads in an application. You lock things.

QueryServiceStatusEx: This old answer of mine, though messy, may contain links to help you: Other installation In Progress Hanging my Wix Install.

The Painter-Factor: Chris Painter - MSI and .NET expert - Has an answer here that I have never tried, but it looks great: check for windows installer mutex availability.

Github.com Pillage?: I find that github.com giveth a lot at times (what a fun word - "kid in a candy store") - maybe have a quick pillage session? Quick sample. Not sure if this can be done in VBScript or Python, but I see some Powershell stuff.


Links:

Upvotes: 3

MofX
MofX

Reputation: 1567

One idea that comes to mind: Write a custom wrapper for msiexec.exe, that uses a named mutex to block until the previous instance of the wrapper has finished

Upvotes: 0

Related Questions