cpython: a161081e8f7c (original) (raw)

--- a/Lib/subprocess.py +++ b/Lib/subprocess.py @@ -371,8 +371,9 @@ class TimeoutExpired(SubprocessError): """This exception is raised when the timeout expires while waiting for a child process. """

def str(self): @@ -533,7 +534,7 @@ def check_output(*popenargs, timeout=Non except TimeoutExpired: process.kill() output, unused_err = process.communicate()

@@ -844,7 +845,7 @@ class Popen(object): return (stdout, stderr) try:

@@ -865,12 +866,12 @@ class Popen(object): return endtime - time.time()

if mswindows: @@ -1063,9 +1064,11 @@ class Popen(object): return self.returncode

@@ -1073,7 +1076,7 @@ class Popen(object): if self.returncode is None: result = _subprocess.WaitForSingleObject(self._handle, timeout) if result == _subprocess.WAIT_TIMEOUT:

@@ -1083,7 +1086,7 @@ class Popen(object): fh.close()

@@ -1489,13 +1492,18 @@ class Popen(object): def wait(self, timeout=None, endtime=None): """Wait for child process to terminate. Returns returncode attribute."""

+

+

@@ -1507,7 +1515,7 @@ class Popen(object): break remaining = self._remaining_time(endtime) if remaining <= 0:

@@ -1516,7 +1524,7 @@ class Popen(object): return self.returncode

@@ -1525,9 +1533,11 @@ class Popen(object): self.stdin.close() if _has_poll:

self.wait(timeout=self._remaining_time(endtime)) @@ -1550,7 +1560,7 @@ class Popen(object): return (stdout, stderr)

@@ -1601,7 +1611,7 @@ class Popen(object): if e.args[0] == errno.EINTR: continue raise

# XXX Rewrite these to use non-blocking I/O on the # file objects; they are no longer using C stdio @@ -1625,7 +1635,7 @@ class Popen(object): return (stdout, stderr)

@@ -1667,9 +1677,9 @@ class Popen(object): # According to the docs, returning three empty lists indicates # that the timeout expired. if not (rlist or wlist or xlist):

# XXX Rewrite these to use non-blocking I/O on the # file objects; they are no longer using C stdio

--- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -651,7 +651,9 @@ class ProcessTestCase(BaseTestCase): def test_wait_timeout(self): p = subprocess.Popen([sys.executable, "-c", "import time; time.sleep(0.1)"])