New submission from Andrew Svetlov <andrew.svet...@gmail.com>:

Currently asyncio uses `loop.call_exception_handler()` for logging *fatal* 
exceptions from underlying sockets before calling protocol.connection_lost().

There is a list of exceptions that are not logged: BrokenPipeError,
ConnectionResetError, ConnectionAbortedError

Later ssl.SSLCertVerificationError was added.

There is a request to skip TimeoutError as well: #34148

aiohttp has a bug report about logging SSLError: 
https://github.com/aio-libs/aiohttp/issues/3535

I am pretty sure that the network subsystem can raise other exceptions that 
users don't want to see in logs.

I suggest changing suppression logic to skip logging of *all* OSError 
exceptions and eliminate _FATAL_ERROR_IGNORE list.
OSError is a sign of communication over network to peer, these problems cannot 
be avoided by fixing a program logic.
All other exceptions are indicators for programming errors, the user's source 
code should be fixed to get rid of such problems (e.g. AttributeError raised by 
protocol callback etc). Logging non-OSErrors is pretty nice and desired 
feature. 

Note, the list now contains OSError derived exceptions only, both TimeoutError 
and SSLError falls into this category too.

Not-logged exceptions are not skipped but reported to the user by 
protocol.connection_lost(exc) callback.
User code can (and should) handle them properly.

The fix is very simple, and don't change application logic.
It can be backported to 3.7 as well.

----------
components: asyncio
messages: 343389
nosy: asvetlov, yselivanov
priority: normal
severity: normal
status: open
title: Don't log OSError exceptions in asyncio transports
versions: Python 3.7, Python 3.8

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue37035>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to