Skip to content

Commit ad1e9be

Browse files
committed
only retry known recoverable errors
1 parent 9afc04b commit ad1e9be

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

Lib/asyncio/proactor_events.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -571,13 +571,17 @@ def _loop_reading(self, fut=None):
571571
else:
572572
self._read_fut = self._loop._proactor.recvfrom(self._sock,
573573
self.max_size)
574-
except OSError as exc:
574+
except ConnectionResetError as exc:
575+
# WSARecvFrom() reports a stale ICMP port unreachable
576+
# notification as a synchronous ConnectionResetError when the
577+
# same socket was used to send to an address that is not
578+
# listening. This is transient, so reschedule the read loop
579+
# instead of leaving it dead.
575580
self._protocol.error_received(exc)
576581
if not self._closing:
577-
# The error can be transient, e.g. a ConnectionResetError
578-
# from a stale ICMP port unreachable notification, so
579-
# reschedule the read loop instead of leaving it dead.
580582
self._loop.call_soon(self._loop_reading)
583+
except OSError as exc:
584+
self._protocol.error_received(exc)
581585
except exceptions.CancelledError:
582586
if not self._closing:
583587
raise

0 commit comments

Comments
 (0)