I'm trying to use subprocess32
to timeout a program like so
process = subprocess32.Popen(program, stdin =subprocess32.PIPE,
stdout=subprocess32.PIPE,
stderr=subprocess32.PIPE)
out, err = process.communicate(input_file, timeout=10)
This raises a TypeError
TypeError: __init__() takes at least 3 arguments (2 given)
Without the timeout argument, everything works fine. But I installed subprocess32 specifically for that purpose following this post, Using module 'subprocess' with timeout.
Traceback:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
92 stdout=subprocess32.PIPE,
93 stderr=subprocess32.PIPE)
---> 94 out, err = process.communicate(input_file, timeout=10)
95
96 if "Focus conditions specified by user have been achieved" in out:
C:\Anaconda\lib\site-packages\subprocess32.pyc in communicate(self, input, timeout)
925
926 try:
--> 927 stdout, stderr = self._communicate(input, endtime, timeout)
928 finally:
929 self._communication_started = True
C:\Anaconda\lib\site-packages\subprocess32.pyc in _communicate(self, input, endtime, orig_timeout)
1188 self.stdout_thread.join(self._remaining_time(endtime))
1189 if self.stdout_thread.isAlive():
-> 1190 raise TimeoutExpired(self.args)
1191 if self.stderr is not None:
1192 self.stderr_thread.join(self._remaining_time(endtime))
TypeError: __init__() takes at least 3 arguments (2 given)
My first thought was that I need to specify an endtime
to communicate
, since it says it needs at least 3 arguments, but after reading the docs I saw that
Deprecated since version 3.4: Do not use the endtime parameter. It is was unintentionally exposed in 3.3 but was left undocumented as it was intended to be private for internal use. Use timeout instead.
So now I don't know what the problem is.
Using Python 2.7.11
and subprocess32 3.2.7