summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-01-14 01:10:33 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2015-01-14 01:10:33 (GMT)
commitf651a604075c2dc9a2d7f3d3bd74da374ff8a696 (patch)
tree1fd5b58dcc596b6d4b26b9904076f391040f4f3e /Lib/test
parentc2c12e433aa47149c692eef5e5debd7c475b04c7 (diff)
downloadcpython-f651a604075c2dc9a2d7f3d3bd74da374ff8a696.zip
cpython-f651a604075c2dc9a2d7f3d3bd74da374ff8a696.tar.gz
cpython-f651a604075c2dc9a2d7f3d3bd74da374ff8a696.tar.bz2
Python issue #23173: sync with Tulip
* If an exception is raised during the creation of a subprocess, kill the subprocess (close pipes, kill and read the return status). Log an error in such case. * Fix SubprocessStreamProtocol.connection_made() to handle cancelled waiter. Add unit test cancelling subprocess methods.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_asyncio/test_subprocess.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_subprocess.py b/Lib/test/test_asyncio/test_subprocess.py
index 5fc1dc0..b2f1b95 100644
--- a/Lib/test/test_asyncio/test_subprocess.py
+++ b/Lib/test/test_asyncio/test_subprocess.py
@@ -251,6 +251,42 @@ class SubprocessMixin:
self.loop.run_until_complete(cancel_wait())
+ def test_cancel_make_subprocess_transport_exec(self):
+ @asyncio.coroutine
+ def cancel_make_transport():
+ coro = asyncio.create_subprocess_exec(*PROGRAM_BLOCKED,
+ loop=self.loop)
+ task = self.loop.create_task(coro)
+
+ self.loop.call_soon(task.cancel)
+ try:
+ yield from task
+ except asyncio.CancelledError:
+ pass
+
+ # ignore the log:
+ # "Exception during subprocess creation, kill the subprocess"
+ with test_utils.disable_logger():
+ self.loop.run_until_complete(cancel_make_transport())
+
+ def test_cancel_post_init(self):
+ @asyncio.coroutine
+ def cancel_make_transport():
+ coro = self.loop.subprocess_exec(asyncio.SubprocessProtocol,
+ *PROGRAM_BLOCKED)
+ task = self.loop.create_task(coro)
+
+ self.loop.call_soon(task.cancel)
+ try:
+ yield from task
+ except asyncio.CancelledError:
+ pass
+
+ # ignore the log:
+ # "Exception during subprocess creation, kill the subprocess"
+ with test_utils.disable_logger():
+ self.loop.run_until_complete(cancel_make_transport())
+
if sys.platform != 'win32':
# Unix