# HG changeset patch # User John Szakmeister # Date 1362570063 18000 # Branch 3.3 # Node ID 46614c5b06919083c8f2ca2983f9d973433307b2 # Parent f4e00073e80c651aebcc07920eea92783e204d7d Fix subprocess communicate() deadlock. It's possible that the fh.read() gets interrupted in _readerthread(), which means that the entirety of stdout or stderr is not consumed. As a result, p.communicate() will never return, as the subprocess is waiting for its output buffer to be read. To fix this, let's retry the read operation if we've been interrupted, just like we do in the optimized case where only one of stdout or stderr is a PIPE. diff -r f4e00073e80c -r 46614c5b0691 Lib/subprocess.py --- a/Lib/subprocess.py Tue Jan 22 15:58:14 2013 +0000 +++ b/Lib/subprocess.py Wed Mar 06 06:41:03 2013 -0500 @@ -1166,7 +1166,7 @@ def _readerthread(self, fh, buffer): - buffer.append(fh.read()) + buffer.append(_eintr_retry_call(fh.read)) fh.close()