Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c94a93a

Browse files
committed
asyncio: Don't log ConnectionAbortedError
Issue #26509: In fatal error handlers, don't log ConnectionAbortedError which occur on Windows.
1 parent 2ba8ece commit c94a93a

5 files changed

Lines changed: 10 additions & 5 deletions

File tree

Lib/asyncio/base_events.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@
5454
# before cleanup of cancelled handles is performed.
5555
_MIN_CANCELLED_TIMER_HANDLES_FRACTION = 0.5
5656

57+
# Exceptions which must not call the exception handler in fatal error
58+
# methods (_fatal_error())
59+
_FATAL_ERROR_IGNORE = (BrokenPipeError,
60+
ConnectionResetError, ConnectionAbortedError)
61+
62+
5763
def _format_handle(handle):
5864
cb = handle._callback
5965
if inspect.ismethod(cb) and isinstance(cb.__self__, tasks.Task):

Lib/asyncio/proactor_events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def __del__(self):
9090
self.close()
9191

9292
def _fatal_error(self, exc, message='Fatal error on pipe transport'):
93-
if isinstance(exc, (BrokenPipeError, ConnectionResetError)):
93+
if isinstance(exc, base_events._FATAL_ERROR_IGNORE):
9494
if self._loop.get_debug():
9595
logger.debug("%r: %s", self, message, exc_info=True)
9696
else:

Lib/asyncio/selector_events.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -578,8 +578,7 @@ def __del__(self):
578578

579579
def _fatal_error(self, exc, message='Fatal error on transport'):
580580
# Should be called from exception handler only.
581-
if isinstance(exc, (BrokenPipeError,
582-
ConnectionResetError, ConnectionAbortedError)):
581+
if isinstance(exc, base_events._FATAL_ERROR_IGNORE):
583582
if self._loop.get_debug():
584583
logger.debug("%r: %s", self, message, exc_info=True)
585584
else:

Lib/asyncio/sslproto.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ def _process_write_backlog(self):
655655

656656
def _fatal_error(self, exc, message='Fatal error on transport'):
657657
# Should be called from exception handler only.
658-
if isinstance(exc, (BrokenPipeError, ConnectionResetError)):
658+
if isinstance(exc, base_events._FATAL_ERROR_IGNORE):
659659
if self._loop.get_debug():
660660
logger.debug("%r: %s", self, message, exc_info=True)
661661
else:

Lib/asyncio/unix_events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ def abort(self):
575575

576576
def _fatal_error(self, exc, message='Fatal error on pipe transport'):
577577
# should be called by exception handler only
578-
if isinstance(exc, (BrokenPipeError, ConnectionResetError)):
578+
if isinstance(exc, base_events._FATAL_ERROR_IGNORE):
579579
if self._loop.get_debug():
580580
logger.debug("%r: %s", self, message, exc_info=True)
581581
else:

0 commit comments

Comments
 (0)