summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/selector_events.py
diff options
context:
space:
mode:
authorjb2170 <email@jb2170.com>2025-01-03 10:32:36 (GMT)
committerGitHub <noreply@github.com>2025-01-03 10:32:36 (GMT)
commit830e10651b1f45cd0af36ff611397b9f53171220 (patch)
tree3984d016964a91bdfa4b158b593c0ff494afcfd2 /Lib/asyncio/selector_events.py
parentbb2dfadb9221fa3035fda42a2c153c831013e3d3 (diff)
downloadcpython-830e10651b1f45cd0af36ff611397b9f53171220.zip
cpython-830e10651b1f45cd0af36ff611397b9f53171220.tar.gz
cpython-830e10651b1f45cd0af36ff611397b9f53171220.tar.bz2
gh-127529: Correct asyncio's `accept_connection` behaviour for handling `ConnectionAbortedError` (#127532)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Diffstat (limited to 'Lib/asyncio/selector_events.py')
-rw-r--r--Lib/asyncio/selector_events.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/Lib/asyncio/selector_events.py b/Lib/asyncio/selector_events.py
index f1ab9b1..50992a6 100644
--- a/Lib/asyncio/selector_events.py
+++ b/Lib/asyncio/selector_events.py
@@ -180,9 +180,13 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop):
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,