diff options
author | Yury Selivanov <yury@magic.io> | 2018-05-29 21:20:02 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-29 21:20:02 (GMT) |
commit | 863b6749093a86810c4077112a857363410cc221 (patch) | |
tree | 398e2d2b175f3a40b31ba89137e9300c5615bef3 /Lib/test/test_asyncio | |
parent | 1cee216cf383eade641aed22f4ec7d4cb565ecff (diff) | |
download | cpython-863b6749093a86810c4077112a857363410cc221.zip cpython-863b6749093a86810c4077112a857363410cc221.tar.gz cpython-863b6749093a86810c4077112a857363410cc221.tar.bz2 |
bpo-32684: Fix gather to propagate cancel of itself with return_exceptions (GH-7209)
Diffstat (limited to 'Lib/test/test_asyncio')
-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 33300c9..1280584 100644 --- a/Lib/test/test_asyncio/test_tasks.py +++ b/Lib/test/test_asyncio/test_tasks.py @@ -2037,7 +2037,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() @@ -2067,6 +2067,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), + return_exceptions=True, + loop=loop) + if time > 1: + return + + async def main(): + qwe = asyncio.Task(test()) + await asyncio.sleep(0.2) + 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 |