python - 检查 python 的 subprocess.Popen 中的异常
问题描述
我正在使用 pythonsubprocess.Popen
来运行 shell 进程(使用shell=True
)。
我没有使用subprocess.check_output
,因为我不想阻塞并且我想不断地取回进程的标准输出,我可以通过迭代Popen
'sstdout
成员来做到这一点。
有没有办法检查Popen
(with shell=True
) 中发生的异常/错误?
我希望有与 in 类似的便利check_output
,其中异常冒泡为CalledProcessError
.
解决方案
推荐阅读
- python - numpy reshape 函数 - 类型错误:顺序必须是 str,而不是 int
- asp.net - 从 IIS 10 随机获取 Erro 500
- python - CNN Pytorch:创建自己的模型时要使用哪些参数?
- excel - Excel VBA循环遍历范围并删除空格和空格之前的文本
- scala - 尽管 maxRetries < 5 且 > 0,但 Akka RestartSource 会永远重试
- android - 如何使用 if 条件 i(我想检索那些名称 = 香蕉或类似的值,根据我的代码使用的条件是什么)
- python - 需要帮助修改轴范围以适应不同的条形图进行分析
- google-sheets - 如果单元格被清除,则插入公式
- smartsheet-api - 如何通过 UI 手动或通过 fetch-request 获取 smartsheet 列的 ID
- serenity-platform - 为什么 Serenity 更新按钮不起作用