summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio/test_subprocess.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-12-11 22:30:17 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-12-11 22:30:17 (GMT)
commit1e40f10886f1c83e47f69ab229b27ab2eceff939 (patch)
treec179e9c1d536065d17c2c3dbc09576272dbd2ce5 /Lib/test/test_asyncio/test_subprocess.py
parentdf75d5b402fa7d9377dd6e38f3ad7551de6746d5 (diff)
downloadcpython-1e40f10886f1c83e47f69ab229b27ab2eceff939.zip
cpython-1e40f10886f1c83e47f69ab229b27ab2eceff939.tar.gz
cpython-1e40f10886f1c83e47f69ab229b27ab2eceff939.tar.bz2
asyncio, tulip issue 209: Fix subprocess for close_fds=False on Python 3.3
Mark the write end of the stdin pipe as non-inheritable.
Diffstat (limited to 'Lib/test/test_asyncio/test_subprocess.py')
-rw-r--r--Lib/test/test_asyncio/test_subprocess.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_subprocess.py b/Lib/test/test_asyncio/test_subprocess.py
index 9060b9d..5c0a2c8 100644
--- a/Lib/test/test_asyncio/test_subprocess.py
+++ b/Lib/test/test_asyncio/test_subprocess.py
@@ -198,6 +198,27 @@ class SubprocessMixin:
self.assertTrue(transport.pause_reading.called)
self.assertTrue(transport.resume_reading.called)
+ def test_stdin_not_inheritable(self):
+ # Tulip issue #209: stdin must not be inheritable, otherwise
+ # the Process.communicate() hangs
+ @asyncio.coroutine
+ def len_message(message):
+ code = 'import sys; data = sys.stdin.read(); print(len(data))'
+ proc = yield from asyncio.create_subprocess_exec(
+ sys.executable, '-c', code,
+ stdin=asyncio.subprocess.PIPE,
+ stdout=asyncio.subprocess.PIPE,
+ stderr=asyncio.subprocess.PIPE,
+ close_fds=False,
+ loop=self.loop)
+ stdout, stderr = yield from proc.communicate(message)
+ exitcode = yield from proc.wait()
+ return (stdout, exitcode)
+
+ output, exitcode = self.loop.run_until_complete(len_message(b'abc'))
+ self.assertEqual(output.rstrip(), b'3')
+ self.assertEqual(exitcode, 0)
+
if sys.platform != 'win32':
# Unix