[issue25489] sys.exit() caught in async event loop exception handler

Guido van Rossum report at bugs.python.org
Tue Mar 22 00:50:29 EDT 2022


Guido van Rossum <guido at python.org> added the comment:

Andrew, thanks for explaining this.

The key thing I was missing was that the root cause of the problem is that Future.__del__ is trying to log an error about the un-awaited task by calling the exception handler directly. That actually feels a little dodgy.

This is why I'm not yet comfortable with (d). Looking at call_exception_handler(), whether it calls the default handler or a custom handler, it explicitly checks for SystemExit and KeyboardInterrupt and re-raises those. And only those -- everything ends up logging an error.

Which makes me wonder. Maybe that error in Future.__del__ should not call any exception handler at all, but just call logger.error()? Or maybe Future.__del__ should catch exceptions coming out of there and log an error? Maybe a modified version of (d), but only implemented in Future.__del__, not in call_exception_handler()?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue25489>
_______________________________________


More information about the Python-bugs-list mailing list