[Python-checkins] cpython (merge 3.4 -> default): Merge 3.4 (asyncio)

victor.stinner python-checkins at python.org
Tue Jan 6 01:23:55 CET 2015


https://hg.python.org/cpython/rev/bfd35f76fd0b
changeset:   94036:bfd35f76fd0b
parent:      94034:454e04786fcc
parent:      94035:990ce80d8283
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Tue Jan 06 01:22:54 2015 +0100
summary:
  Merge 3.4 (asyncio)

files:
  Lib/test/test_asyncio/test_subprocess.py |  14 +++++------
  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
--- a/Lib/test/test_asyncio/test_subprocess.py
+++ b/Lib/test/test_asyncio/test_subprocess.py
@@ -227,20 +227,18 @@
         # 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()

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list