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

Skip to content
Next Next commit
Fix gh-127529: Correct asyncio.selector_events.BaseSelectorEventLoop.…
…_accept_connection's behaviour for handling ConnectionAbortedError
  • Loading branch information
jb2170 committed Dec 2, 2024
commit 7ab314941e3d02b681207b4bb655c9697481507f
10 changes: 7 additions & 3 deletions Lib/asyncio/selector_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,13 @@ def _accept_connection(
logger.debug("%r got a new connection from %r: %r",
server, addr, conn)
conn.setblocking(False)
except (BlockingIOError, InterruptedError, ConnectionAbortedError):
# Early exit because the socket accept buffer is empty.
return None
except ConnectionAbortedError:
# Discard connections that were aborted before accept().
continue
except (BlockingIOError, InterruptedError):
# Early exit because of a signal or
# the socket accept buffer is empty.
return
except OSError as exc:
# There's nowhere to send the error, so just log it.
if exc.errno in (errno.EMFILE, errno.ENFILE,
Expand Down