summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-01-15 15:29:10 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2015-01-15 15:29:10 (GMT)
commit922bc2ca123630aa9cff63c605a82af05408318d (patch)
tree98bdd9abdbeabc074bd223e598f52eb9f0c4844f /Lib/test
parentab8848bc2a64930e0e9a2e56592bb692fb31d9e9 (diff)
downloadcpython-922bc2ca123630aa9cff63c605a82af05408318d.zip
cpython-922bc2ca123630aa9cff63c605a82af05408318d.tar.gz
cpython-922bc2ca123630aa9cff63c605a82af05408318d.tar.bz2
Closes #23219: cancelling asyncio.wait_for() now cancels the task
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_asyncio/test_tasks.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py
index 7807dc0..06447d7 100644
--- a/Lib/test/test_asyncio/test_tasks.py
+++ b/Lib/test/test_asyncio/test_tasks.py
@@ -1705,6 +1705,33 @@ class TaskTests(test_utils.TestCase):
'test_task_source_traceback'))
self.loop.run_until_complete(task)
+ def _test_cancel_wait_for(self, timeout):
+ loop = asyncio.new_event_loop()
+ self.addCleanup(loop.close)
+
+ @asyncio.coroutine
+ def blocking_coroutine():
+ fut = asyncio.Future(loop=loop)
+ # Block: fut result is never set
+ yield from fut
+
+ task = loop.create_task(blocking_coroutine())
+
+ wait = loop.create_task(asyncio.wait_for(task, timeout, loop=loop))
+ loop.call_soon(wait.cancel)
+
+ self.assertRaises(asyncio.CancelledError,
+ loop.run_until_complete, wait)
+
+ # Python issue #23219: cancelling the wait must also cancel the task
+ self.assertTrue(task.cancelled())
+
+ def test_cancel_blocking_wait_for(self):
+ self._test_cancel_wait_for(None)
+
+ def test_cancel_wait_for(self):
+ self._test_cancel_wait_for(60.0)
+
class GatherTestsBase: