我有以下 Python 代码:
strRunOutput = subprocess.run([strFastbootExecutable, "-s", dsn.upper(), "reboot"], timeout=5, stderr=subprocess.PIPE).stderr.decode('utf-8').upper()
Run Code Online (Sandbox Code Playgroud)
这基本上是这样做的:
fastboot -s G070GV1871970FCW reboot
Run Code Online (Sandbox Code Playgroud)
这是输出:
< waiting for G070GV1871970FCW >
Run Code Online (Sandbox Code Playgroud)
...这是挂。为什么 fastboot 命令挂起,我不知道,但更让我烦恼的是 subprocess.run 命令在我告诉它的 5 秒后没有超时,并导致我的程序挂起。任何想法发生了什么?
谢谢!
这是一个已知问题 - Python 错误跟踪器上有两张与之相关的票。
这不是因为您连接了管道而超时。
问题 31935:subprocess.run() 超时不适用于孙子和 stdout=PIPE 问题
30154:使用连接到管道的 stderr 的 subprocess.run 在杀死永无止境的 shell 命令时不会超时(原文如此)
| 归档时间: |
|
| 查看次数: |
1718 次 |
| 最近记录: |