mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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.
This commit is contained in:
parent
682124ccc3
commit
c8bd53f815
2 changed files with 30 additions and 2 deletions
|
@ -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.')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue