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/asyncio | |
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/asyncio')
-rw-r--r-- | Lib/asyncio/base_events.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py index 3cff72a..b6b7123 100644 --- a/Lib/asyncio/base_events.py +++ b/Lib/asyncio/base_events.py @@ -268,7 +268,15 @@ class BaseEventLoop(events.AbstractEventLoop): future._log_destroy_pending = False future.add_done_callback(_raise_stop_error) - self.run_forever() + try: + self.run_forever() + except: + if new_task and future.done() and not future.cancelled(): + # The coroutine raised a BaseException. Consume the exception + # to not log a warning, the caller doesn't have access to the + # local task. + future.exception() + raise future.remove_done_callback(_raise_stop_error) if not future.done(): raise RuntimeError('Event loop stopped before Future completed.') |