python\uyu init_uu()获得意外的关键字参数“timeout”

2024-05-14 17:50:16 发布

您现在位置:Python中文网/ 问答频道 /正文

我有下面的代码,超时设置为60秒

p = subprocess.Popen(['ocamlopt', file], \
                     stdout=subprocess.PIPE, \
                     stderr=subprocess.PIPE, \
                     timeout=TIMEOUT_ECAML, \
                     )

我不明白为什么我收到的错误消息

^{pr2}$

我用相同的错误查看了this previous post,但是另一个用户在我使用subprocess.Popen()时使用了subprocess.call(),所以我很困惑为什么会发生这种情况。在


Tags: 代码消息错误stderrstdouttimeoutthisfile
3条回答

同样的原因。没有超时参数。在

Popen的所有有效参数的列表:https://docs.python.org/3/library/subprocess.html#subprocess.Popen

the other user uses subprocess.call() while I am using subprocess.Popen() so I am confused why this is happening.

call()阻塞,直到命令结束或超时。Popen()不等待命令完成;它立即返回,因此不接受timeout参数。您可以将timeout传递给wait()communicate()方法,这些方法会一直等到进程完成或超时。在

相关问题 更多 >

    热门问题