classification
Title: Don't log OSError exceptions in asyncio transports
Type: Stage: resolved
Components: asyncio Versions: Python 3.8, Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Harmon758, asvetlov, miss-islington, yselivanov
Priority: normal Keywords: patch

Created on 2019-05-24 14:32 by asvetlov, last changed 2019-10-13 03:56 by Harmon758. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 13548 merged asvetlov, 2019-05-24 15:11
PR 13594 merged asvetlov, 2019-05-27 14:27
Messages (4)
msg343389 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2019-05-24 14:32
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.
msg343390 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2019-05-24 14:35
Update.
Currently, exceptions from the ignore list are still logged in debug mode. The proposal doesn't change this behavior.
msg343623 - (view) Author: miss-islington (miss-islington) Date: 2019-05-27 13:28
New changeset 1f39c28e489cca0397fc4c3675d13569318122ac by Miss Islington (bot) (Andrew Svetlov) in branch 'master':
bpo-37035: Don't log OSError (GH-13548)
https://github.com/python/cpython/commit/1f39c28e489cca0397fc4c3675d13569318122ac
msg343651 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2019-05-27 15:52
New changeset a79b6c578fcd2ea8be29440fdd8a998e5527200f by Andrew Svetlov in branch '3.7':
[3.7] bpo-37035: Don't log OSError (GH-13548) (#13594)
https://github.com/python/cpython/commit/a79b6c578fcd2ea8be29440fdd8a998e5527200f
History
Date User Action Args
2019-10-13 03:56:22Harmon758setnosy: + Harmon758
2019-06-17 11:40:59asvetlovlinkissue34506 superseder
2019-05-27 15:52:27asvetlovsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2019-05-27 15:52:08asvetlovsetmessages: + msg343651
2019-05-27 14:27:54asvetlovsetpull_requests: + pull_request13501
2019-05-27 13:47:27asvetlovlinkissue34148 superseder
2019-05-27 13:28:37miss-islingtonsetnosy: + miss-islington
messages: + msg343623
2019-05-24 15:11:49asvetlovsetkeywords: + patch
stage: patch review
pull_requests: + pull_request13460
2019-05-24 14:35:41asvetlovsetmessages: + msg343390
2019-05-24 14:32:57asvetlovcreate