Title: Don't log an exception from the main coroutine in
Type: Stage:
Components: asyncio Versions: Python 3.8
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: asvetlov, scotchka, yselivanov
Priority: normal Keywords: easy

Created on 2019-01-24 00:58 by asvetlov, last changed 2019-02-06 06:16 by scotchka.

File name Uploaded Description Edit asvetlov, 2019-01-24 00:58
Messages (2)
msg334276 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2019-01-24 00:58
We use `` (well, a backported to python3.6 private copy) in our application.

The problem is: when `` raises an exception it is both raised to a caller and passed to `loop.call_exception_handler()` by `_cancel_all_tasks()` as *unhandled exception*.

I believe that the logging of unhandled exceptions is a very useful feature but the logging should be skipped for the main coroutine passed to `` because it is handled by outer code anyway.

The fix is trivial, the attached file shows how to do it.
But the fix needs tests also.

If somebody wishes to pick up the issue and make it done -- it would be awesome. I will help with review and commit, sure.

Another question is should the changing land into 3.7?
I think yes but feedback from Yuri Selivanov is very welcome.
msg334903 - (view) Author: Henry Chen (scotchka) * Date: 2019-02-06 06:16
I'm having trouble reproducing this issue. The main_coro seems to disappear when an exception is raised in it, so that it does not show up in the set of tasks to cancel. I'm probably misunderstanding something basic here. Is it possible to provide a minimal example?
Date User Action Args
2019-02-06 06:16:48scotchkasetnosy: + scotchka
messages: + msg334903
2019-01-24 00:58:51asvetlovcreate