Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

__init__() got an unexpected keyword argument 'timeout' in python 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.

like image 870
Chamila Wijayarathna Avatar asked Aug 20 '26 06:08

Chamila Wijayarathna


1 Answers

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

like image 79
timgeb Avatar answered Aug 22 '26 21:08

timgeb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!