diff options
author | Yury Selivanov <yury@magic.io> | 2018-05-29 23:20:01 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-29 23:20:01 (GMT) |
commit | 3b263e65a80cfcb1fc751834372533773ec024a4 (patch) | |
tree | bc9c9a1361efdee8025f0f85636fb5e54b2f81cd /Lib/test/test_asyncio/test_tasks.py | |
parent | 51bf38f796c74c7dac5a3d09ad0004494470091c (diff) | |
download | cpython-3b263e65a80cfcb1fc751834372533773ec024a4.zip cpython-3b263e65a80cfcb1fc751834372533773ec024a4.tar.gz cpython-3b263e65a80cfcb1fc751834372533773ec024a4.tar.bz2 |
bpo-32684: Fix gather to propagate cancel of itself with return_exceptions (GH-7224)
Diffstat (limited to 'Lib/test/test_asyncio/test_tasks.py')
-rw-r--r-- | Lib/test/test_asyncio/test_tasks.py | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py index f41160b..7c51873 100644 --- a/Lib/test/test_asyncio/test_tasks.py +++ b/Lib/test/test_asyncio/test_tasks.py @@ -1991,7 +1991,7 @@ class BaseTaskTests: def test_cancel_wait_for(self): self._test_cancel_wait_for(60.0) - def test_cancel_gather(self): + def test_cancel_gather_1(self): """Ensure that a gathering future refuses to be cancelled once all children are done""" loop = asyncio.new_event_loop() @@ -2021,6 +2021,33 @@ class BaseTaskTests: self.assertFalse(gather_task.cancelled()) self.assertEqual(gather_task.result(), [42]) + def test_cancel_gather_2(self): + loop = asyncio.new_event_loop() + self.addCleanup(loop.close) + + async def test(): + time = 0 + while True: + time += 0.05 + await asyncio.gather(asyncio.sleep(0.05, loop=loop), + return_exceptions=True, + loop=loop) + if time > 1: + return + + async def main(): + qwe = self.new_task(loop, test()) + await asyncio.sleep(0.2, loop=loop) + qwe.cancel() + try: + await qwe + except asyncio.CancelledError: + pass + else: + self.fail('gather did not propagate the cancellation request') + + loop.run_until_complete(main()) + def test_exception_traceback(self): # See http://bugs.python.org/issue28843 |