__init__() 在 python 子进程中有一个意外的关键字参数“超时" [英] __init__() got an unexpected keyword argument 'timeout' in python subprocess

查看:46
本文介绍了__init__() 在 python 子进程中有一个意外的关键字参数“超时"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行以下使用 pythos 'subprocess' 模块的代码.

I am trying to run following code which uses pythos 'subprocess' module.

subprocess.call(cli_args, stdout=client_log, stderr=client_log, timeout=10)

我正在使用超时争论,这是在此处提到的以跳过此如果子进程卡在中间,则通过杀死它来行.但是当我运行这个时,我收到以下错误.

I am using timeout arguement, which is mentioned here to skip from this line if the subprocess stuck at the middle, by killing it. But when I run this, I am getting following error.

Traceback (most recent call last):
  File "test.py", line 152, in <module>
    ret = runServiceTest(test_name, server_executable, server_extra_args, client_executable, client_extra_args, protocol, transport, 9090, 0, 0)
  File "test.py", line 102, in runServiceTest
    ret = subprocess.call(cli_args, stdout=client_log, stderr=client_log, timeout=10)
  File "/usr/lib/python2.7/subprocess.py", line 522, in call
    return Popen(*popenargs, **kwargs).wait()
TypeError: __init__() got an unexpected keyword argument 'timeout'

这是什么原因?我该如何解决这个问题?我的完整代码可以在此处找到.

What is the reason for this? How can I solve this? My complete code can be found here.

推荐答案

根据您的 print 语句判断,您使用的是 Python2.x,其中 subprocess.call 没有有一个 timeout 参数:

Judging by your print statements, you are using Python2.x, where subprocess.call does not have a timeout argument:

subprocess.call(args, *, stdin=None, stdout=None, stderr=None, shell=False)

https://docs.python.org/2/library/subprocess.html

这篇关于__init__() 在 python 子进程中有一个意外的关键字参数“超时"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆