[New-bugs-announce] [issue35812] Don't log an exception from the main coroutine in asyncio.run()
report at bugs.python.org
Wed Jan 23 19:58:52 EST 2019
New submission from Andrew Svetlov <andrew.svetlov at gmail.com>:
We use `asyncio.run()` (well, a backported to python3.6 private copy) in our application.
The problem is: when `asyncio.run(main_coro(args))` 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 `asyncio.run()` 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.
nosy: asvetlov, yselivanov
title: Don't log an exception from the main coroutine in asyncio.run()
versions: Python 3.8
Added file: https://bugs.python.org/file48074/utils.py
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce