summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio/test_subprocess.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-01-06 00:22:45 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2015-01-06 00:22:45 (GMT)
commit212994e4e2ed023267ebfceeae541c8aa4257806 (patch)
treee2e0d6b8c94ebb757387b76e82a51b3766f4a833 /Lib/test/test_asyncio/test_subprocess.py
parentc447ba04e78a91c1febe7744b9e6cbcdd3e23360 (diff)
downloadcpython-212994e4e2ed023267ebfceeae541c8aa4257806.zip
cpython-212994e4e2ed023267ebfceeae541c8aa4257806.tar.gz
cpython-212994e4e2ed023267ebfceeae541c8aa4257806.tar.bz2
Issue #23140, asyncio: Simplify the unit test
Diffstat (limited to 'Lib/test/test_asyncio/test_subprocess.py')
-rw-r--r--Lib/test/test_asyncio/test_subprocess.py14
1 files changed, 6 insertions, 8 deletions
diff --git a/Lib/test/test_asyncio/test_subprocess.py b/Lib/test/test_asyncio/test_subprocess.py
index dfe23be..1fe9095 100644
--- a/Lib/test/test_asyncio/test_subprocess.py
+++ b/Lib/test/test_asyncio/test_subprocess.py
@@ -227,20 +227,18 @@ class SubprocessMixin:
# Issue #23140: cancel Process.wait()
@asyncio.coroutine
- def wait_proc(proc, event):
- event.set()
- yield from proc.wait()
-
- @asyncio.coroutine
def cancel_wait():
proc = yield from asyncio.create_subprocess_exec(
*PROGRAM_BLOCKED,
loop=self.loop)
# Create an internal future waiting on the process exit
- event = asyncio.Event(loop=self.loop)
- task = self.loop.create_task(wait_proc(proc, event))
- yield from event.wait()
+ task = self.loop.create_task(proc.wait())
+ self.loop.call_soon(task.cancel)
+ try:
+ yield from task
+ except asyncio.CancelledError:
+ pass
# Cancel the future
task.cancel()