40129

__init__() got an unexpected keyword argument 'timeout' in python subprocess

Question:

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 <a href="https://docs.python.org/3.5/library/subprocess.html" rel="nofollow">here</a> 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 <a href="https://gist.github.com/cdwijayarathna/3dfe4f37c5db1400672f" rel="nofollow">here</a>.

Answer1:

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)

<a href="https://docs.python.org/2/library/subprocess.html" rel="nofollow">https://docs.python.org/2/library/subprocess.html</a>

Recommend

  • Spark Worker asking for absurd amounts of virtual memory
  • Can I really not clean up when Visual Studio stops debugging?
  • What is an alternative to Sendkeys for closing a legacy application?
  • Centering a specific element among others with flexbox [duplicate]
  • Is it really posible to close a PhoneGap App?
  • Is there a way to pivot a customer ID and a their most recent order dates?
  • ValueError: Found arrays with inconsistent numbers of samples
  • user data scripts fails without giving reason
  • Cannot find “Grammar.txt” in python-sphinx
  • Rodeo UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 0: ordinal
  • Python 3.2.2, error(scripts to exe)
  • pillow imaging ImportError
  • Position: fixed nav does not stay fixed
  • Django simple Captcha “No module named fields” error
  • Debug.DrawLine not showing in the GameView
  • How to know when stdin is empty if it contains EOF?
  • Display issues when we change from one jquery mobile page to another in firefox
  • Deselecting radio buttons while keeping the View Model in synch
  • Array.prototype.includes - not transformed with babel
  • Volley JsonObjectRequest send headers in GET Request
  • Accessing IRQ description array within a module and displaying action names
  • JSON with duplicate key names losing information when parsed
  • Can a Chrome extension content script make an jQuery AJAX request for an html file that is itself a
  • Build own AppleScript numerical error handling
  • Websockets service method fails during R startup
  • Jquery - Jquery Wysiwyg return html as a string
  • Google cloud sdk not working when python points python3
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Is there a mandatory requirement to switch app.yaml?
  • Load html files in TinyMce
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • Hits per day in Google Big Query
  • coudnt use logback because of log4j
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Linking SubReports Without LinkChild/LinkMaster
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • UserPrincipal.Current returns apppool on IIS
  • java string with new operator and a literal