Skip to content

gh-156920, gh-156698: fix ProactorEventLoop datagram transport hangs on close() and after write errors - #156921

Open
graingert wants to merge 20 commits into
python:mainfrom
graingert:fix-proactor-close-flush
Open

gh-156920, gh-156698: fix ProactorEventLoop datagram transport hangs on close() and after write errors#156921
graingert wants to merge 20 commits into
python:mainfrom
graingert:fix-proactor-close-flush

Conversation

@graingert

@graingert graingert commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

@graingert
graingert marked this pull request as ready for review September 10, 2026 16:49
@graingert graingert changed the title gh-156920: fix ProactorEventLoop datagram transports drop buffered datagrams on close() and never call connection_lost() gh-156920, gh-156698: fix ProactorEventLoop datagram transport hangs on close() and after write errors Sep 11, 2026
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.
@graingert graingert added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Sep 11, 2026
@kumaraditya303

Copy link
Copy Markdown
Contributor

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

@graingert

Copy link
Copy Markdown
Contributor Author

@kumaraditya303 thanks for spotting that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants