From: Victor Stinner Date: Tue, 5 Jul 2011 12:04:39 +0000 (+0200) Subject: (merge 3.2) Issue #12493: subprocess: communicate() handles EINTR X-Git-Tag: v3.3.0a1~1946 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5b1261d750793539cf4508a1e76c2f6d20900ac7;p=thirdparty%2FPython%2Fcpython.git (merge 3.2) Issue #12493: subprocess: communicate() handles EINTR subprocess.Popen.communicate() now also handles EINTR errors if the process has only one pipe. --- 5b1261d750793539cf4508a1e76c2f6d20900ac7 diff --cc Lib/subprocess.py index cfd4c85584c9,0523219b5a68..83e6c407c7bb --- a/Lib/subprocess.py +++ b/Lib/subprocess.py @@@ -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): diff --cc Misc/NEWS index e5e188ed4f54,ae0ed58226e2..5d1530adb5a4 --- a/Misc/NEWS +++ 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.