diff options
| author | Victor Stinner <victor.stinner@gmail.com> | 2014-10-11 12:30:18 (GMT) |
|---|---|---|
| committer | Victor Stinner <victor.stinner@gmail.com> | 2014-10-11 12:30:18 (GMT) |
| commit | c8bd53f81512acf805708abca31f5491c13ae185 (patch) | |
| tree | 01813c7bac8fb724a4435ff4de774ba41e6cb6c0 /Lib/test/test_asyncio/test_base_events.py | |
| parent | 682124ccc3c7e07006ca99346f749689a5229459 (diff) | |
| download | cpython-c8bd53f81512acf805708abca31f5491c13ae185.zip cpython-c8bd53f81512acf805708abca31f5491c13ae185.tar.gz cpython-c8bd53f81512acf805708abca31f5491c13ae185.tar.bz2 | |
Issue #22601: run_forever() now consumes BaseException of the temporary task
If the coroutine raised a BaseException, consume the exception to not log a
warning. The caller doesn't have access to the local task.
Diffstat (limited to 'Lib/test/test_asyncio/test_base_events.py')
| -rw-r--r-- | Lib/test/test_asyncio/test_base_events.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py index 294872a..afc448c 100644 --- a/Lib/test/test_asyncio/test_base_events.py +++ b/Lib/test/test_asyncio/test_base_events.py @@ -9,7 +9,7 @@ import time import unittest from unittest import mock from test.script_helper import assert_python_ok -from test.support import IPV6_ENABLED +from test.support import IPV6_ENABLED, gc_collect import asyncio from asyncio import base_events @@ -618,6 +618,26 @@ class BaseEventLoopTests(test_utils.TestCase): task._log_destroy_pending = False coro.close() + def test_run_forever_keyboard_interrupt(self): + # Python issue #22601: ensure that the temporary task created by + # run_forever() consumes the KeyboardInterrupt and so don't log + # a warning + @asyncio.coroutine + def raise_keyboard_interrupt(): + raise KeyboardInterrupt + + self.loop._process_events = mock.Mock() + self.loop.call_exception_handler = mock.Mock() + + try: + self.loop.run_until_complete(raise_keyboard_interrupt()) + except KeyboardInterrupt: + pass + self.loop.close() + gc_collect() + + self.assertFalse(self.loop.call_exception_handler.called) + class MyProto(asyncio.Protocol): done = None |
