]> granicus.if.org Git - python/commitdiff
(merge 3.2) Issue #12493: subprocess: communicate() handles EINTR
authorVictor Stinner <victor.stinner@haypocalc.com>
Tue, 5 Jul 2011 12:04:39 +0000 (14:04 +0200)
committerVictor Stinner <victor.stinner@haypocalc.com>
Tue, 5 Jul 2011 12:04:39 +0000 (14:04 +0200)
subprocess.Popen.communicate() now also handles EINTR errors if the process has
only one pipe.

1  2 
Lib/subprocess.py
Lib/test/test_subprocess.py
Misc/NEWS

index cfd4c85584c90137b6a44499ccf2ba73e0afa718,0523219b5a68824488b98c4ed8c4d8ee8ed542a3..83e6c407c7bb9595ba00acee6fde07fdf4f79d07
@@@ -820,26 -804,15 +820,26 @@@ class Popen(object)
                              raise
                  self.stdin.close()
              elif self.stdout:
-                 stdout = self.stdout.read()
+                 stdout = _eintr_retry_call(self.stdout.read)
                  self.stdout.close()
              elif self.stderr:
-                 stderr = self.stderr.read()
+                 stderr = _eintr_retry_call(self.stderr.read)
                  self.stderr.close()
              self.wait()
 -            return (stdout, stderr)
 +        else:
 +            if timeout is not None:
 +                endtime = time.time() + timeout
 +            else:
 +                endtime = None
 +
 +            try:
 +                stdout, stderr = self._communicate(input, endtime, timeout)
 +            finally:
 +                self._communication_started = True
  
 -        return self._communicate(input)
 +            sts = self.wait(timeout=self._remaining_time(endtime))
 +
 +        return (stdout, stderr)
  
  
      def poll(self):
Simple merge
diff --cc Misc/NEWS
index e5e188ed4f54cc20cabeaee6902e193ac2e5c0d4,ae0ed58226e23ad889128ced06c4d9010d39d7e7..5d1530adb5a4a0ae2f22d02693d000da14da94bd
+++ b/Misc/NEWS
@@@ -219,21 -98,8 +219,24 @@@ Core and Builtin
  Library
  -------
  
++- Issue #12493: subprocess: Popen.communicate() now also handles EINTR errors
++  if the process has only one pipe.
++
 +- Issue #12467: warnings: fix a race condition if a warning is emitted at
 +  shutdown, if globals()['__file__'] is None.
 +
 +- Issue #12451: pydoc: importfile() now opens the Python script in binary mode,
 +  instead of text mode using the locale encoding, to avoid encoding issues.
 +
 +- Issue #12451: runpy: run_path() now opens the Python script in binary mode,
 +  instead of text mode using the locale encoding, to support other encodings
 +  than UTF-8 (scripts using the coding cookie).
 +
 +- Issue #12451: xml.dom.pulldom: parse() now opens files in binary mode instead
 +  of the text mode (using the locale encoding) to avoid encoding issues.
 +
  - Issue #12147: Adjust the new-in-3.2 smtplib.send_message method for better
 -  conformance to the RFCs: correctly handle Sender and Resent headers.
 +  conformance to the RFCs:  correctly handle Sender and Resent- headers.
  
  - Issue #12352: Fix a deadlock in multiprocessing.Heap when a block is freed by
    the garbage collector while the Heap lock is held.