如何使用subprocess获取终端错误信息?

How to use subprocess to obtain terminal error information?

我正在使用子进程来执行 selenium-side-runner。想获取终端的错误信息,用代码分析错误原因

result = subprocess.Popen(
    [
        "selenium-side-runner",
        "--server",
        settings.SELENIUM_ADDRESS,
        file_path,
    ],
    stdout=subprocess.PIPE
)
try:
    outs, errs = result.communicate(timeout=600)
except subprocess.TimeoutExpired:
    result.kill()
    outs, errs = result.communicate()

但是使用这种方法,我无法在终端中得到类似输出的错误信息。

尝试添加 stderr:

result = subprocess.Popen(
    [
        "selenium-side-runner",
        "--server",
        settings.SELENIUM_ADDRESS,
        file_path,
    ],
    stdout=subprocess.PIPE,
    stderr=subprocess.PIPE
)