gh-156920, gh-156698: fix ProactorEventLoop datagram transport hangs on close() and after write errors - #156921
Conversation
…red datagrams on close() and never call connection_lost()
…ror-hang # Conflicts: # Lib/test/test_asyncio/test_events.py
# Conflicts: # Lib/test/test_asyncio/test_events.py
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
# Conflicts: # Lib/asyncio/proactor_events.py
This reverts commit 4822ab7.
The from_callback variant only reaches the error path after the write has already been armed (and the protocol resumed), so it passes on main; fold the remaining scenario back into a single test.
|
I think you need to add closing check otherwise any _loop_reading() that runs after close() now arms a fresh recvfrom on a closing transport. def _loop_reading(self, fut=None):
data = None
try:
if self._closing:
# close() no longer bumps _conn_lost while a write is still
# being flushed, so gate reads on _closing: after close()
# no more data will be received, and arming a recvfrom()
# here would leave an overlapped read to be aborted when
# connection_lost() closes the socket.
return |
|
@kumaraditya303 thanks for spotting that! |
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Co-authored-by: Thomas Grainger <tagrain@gmail.com>
|
Thanks @graingert for the PR, and @kumaraditya303 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15. |
|
GH-157607 is a backport of this pull request to the 3.15 branch. |
|
GH-157608 is a backport of this pull request to the 3.14 branch. |
|
GH-157609 is a backport of this pull request to the 3.13 branch. |
|
_ProactorDatagramTransportnever resumes a paused protocol after a write error #156698