[issue19293] test_asyncio hanging for 1 hour (AIX version, hangs in test_subprocess_interactive)

Richard Oudkerk report at bugs.python.org
Mon Oct 21 18:19:05 CEST 2013


Richard Oudkerk added the comment:

The following uses socketpair() instead of pipe() for stdin, and works for me on Linux:

diff -r 7d94e4a68b91 asyncio/unix_events.py
--- a/asyncio/unix_events.py    Sun Oct 20 20:25:04 2013 -0700
+++ b/asyncio/unix_events.py    Mon Oct 21 17:15:19 2013 +0100
@@ -272,8 +272,6 @@
         self._loop = loop
         self._pipe = pipe
         self._fileno = pipe.fileno()
-        if not stat.S_ISFIFO(os.fstat(self._fileno).st_mode):
-            raise ValueError("Pipe transport is for pipes only.")
         _set_nonblocking(self._fileno)
         self._protocol = protocol
         self._buffer = []
@@ -442,9 +440,16 @@
         self._finished = False
         self._returncode = None

+        if stdin == subprocess.PIPE:
+            stdin_w, stdin_r = socket.socketpair()
+        else:
+            stdin_w = stdin_r = None
         self._proc = subprocess.Popen(
-            args, shell=shell, stdin=stdin, stdout=stdout, stderr=stderr,
+            args, shell=shell, stdin=stdin_r, stdout=stdout, stderr=stderr,
             universal_newlines=False, bufsize=bufsize, **kwargs)
+        if stdin_r is not None:
+            stdin_r.close()
+            self._proc.stdin = open(stdin_w.detach(), 'rb', buffering=bufsize)
         self._extra['subprocess'] = self._proc

     def close(self):

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19293>
_______________________________________


More information about the Python-bugs-list mailing list