子进程期间的假键盘中断

问题描述

我在使用一段 Python 代码时遇到了一个奇怪的问题,尽管没有人碰过键盘,但有时程序会在运行 KeyboardInterrupt 时因 subprocess 崩溃。这是回溯。它总是发生在同一行。

Logging msiexec uninstaller output to C:\Users\ADMINI~1\AppData\Local\Temp\2\osd_auto_update.log
Traceback (most recent call last):
  File "osd_auto_update.py",line 207,in <module>
  File "osd_auto_update.py",line 158,in main
  File "osd_auto_update.py",line 201,in win_uninstall
  File "subprocess.py",line 507,in run
  File "subprocess.py",line 1126,in communicate
  File "subprocess.py",line 1189,in wait
  File "subprocess.py",line 1470,in _wait
KeyboardInterrupt
[4220] Failed to execute script osd_auto_update

很难调试,因为这种情况只有大约 20% 的时间会发生。我正在使用 PyInstaller 制作的单个文件二进制文件在 Windows 上运行,到目前为止,在没有 PyInstaller 的情况下运行代码时,我无法重现该问题。基本上,代码使用 urllib.requests.urlopen() 下载大型 MSI 安装程序文件 (1.6GB),然后使用 subprocess.run('msiexec') 卸载应用程序,然后安装下载的 MSI,再次以相同方式使用 msiexec。我曾尝试将代码拆开以单独运行每个部分,但到目前为止我只能使用完整程序重现异常。我真的不知道在哪里看。如果机器内存或磁盘空间不足或其他原因,是否有某些情况可能导致这种情况?我还使用 RDP 连接到 Windows 机器...

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...