python - 如何通过 python 脚本使用多处理或任何其他模块序列化 msiexec.exe 安装?

标签 python windows serialization multiprocessing windows-installer

我有一个自动化的 jenkins 作业,它通过 python 脚本运行 msiexec.exe 安装。可以在同一台机器上使用不同的参数启动同一脚本的多个实例。由于 msiexec.exe 一次只能处理 1 个安装,任何启动的并行安装都会引发错误并且 jenkins 作业挂起!

为了避免并行安装,我添加了一个 while 循环来检查是否有任何 msiexec 任务正在运行并等待它完成。但这仍然不是万无一失的,因为我看到了一些竞争条件问题。

需要序列化的步骤:

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

while 循环已经实现:

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

我相信在检查 msiexec 任务是否已完成时,创建进程锁会产生比 while 循环更好的结果。关于如何实现它的任何想法?请注意它必须使用 python 2.7.3 的库存模块部分。安装新模块不是一种选择。

最佳答案

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.


互斥:msiexec.exe sets a mutex同时运行 MSI ( What is a mutex? ) 的 InstallExecuteSequence。这是为了允许在出现错误时回滚安装。因此,有必要防止来自其他 MSI 文件的更改 - 有点像处理应用程序中的多线程。你锁东西。

QueryServiceStatusEx:我的这个旧答案虽然很乱,但可能包含对您有帮助的链接:Other installation In Progress Hanging my Wix Install .

画家因素:Chris Painter - MSI 和 .NET 专家 - 这里有一个我从未尝试过的答案,但它看起来很棒:check for windows installer mutex availability .

Github.com Pillage?:我发现 github.com有时会付出很多(多么有趣的词——“糖果店里的 child ”)——也许有一个快速的掠夺 session ? Quick sample .不确定这是否可以在 VBScript 或 Python 中完成,但我看到了一些 Powershell 的东西。


链接:

关于python - 如何通过 python 脚本使用多处理或任何其他模块序列化 msiexec.exe 安装?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57353728/

相关文章:

Python JSON序列化排除某些字段

用于从 image-net.org 下载图像以进行 haar 级联训练的 python 代码

c - 链接 : making virtual address corresponding to file offset

python - Keras RNN 回归输入维度和架构

python - 是否可以从另一个 python 脚本中运行一个 python 脚本?

windows - 当我尝试拖放一个包含 git 存储库(目前是子模块)的文件夹时,它说 "Can' t drop folder here...”

java - OSGi 中的反序列化问题

java - arraylist如何在序列化后保存数据

python - 在不同主机上并行和后台执行 Fabric 函数

python - 将 float 格式化为 17 个字符 - Python