Skip to content

gh-156698: Fix _ProactorDatagramTransport never resumes a paused protocol after a write error - #156718

Open
graingert wants to merge 8 commits into
python:mainfrom
graingert:fix-proactor-error-hang
Open

gh-156698: Fix _ProactorDatagramTransport never resumes a paused protocol after a write error#156718
graingert wants to merge 8 commits into
python:mainfrom
graingert:fix-proactor-error-hang

Conversation

@graingert

@graingert graingert commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

@graingert graingert changed the title gh-156698: fix proactor error hang gh-156698: _ProactorDatagramTransport never resumes a paused protocol after a write error Aug 31, 2026
@graingert graingert changed the title gh-156698: _ProactorDatagramTransport never resumes a paused protocol after a write error gh-156698: Fix _ProactorDatagramTransport never resumes a paused protocol after a write error Aug 31, 2026
@graingert
graingert marked this pull request as ready for review August 31, 2026 15:18
@graingert
graingert force-pushed the fix-proactor-error-hang branch from a3b797a to 800498e Compare August 31, 2026 17:30
@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 1, 2026
Comment thread Lib/asyncio/proactor_events.py Outdated
@kumaraditya303

Copy link
Copy Markdown
Contributor

Two comments:

  1. Resume on a dead transport. If error_received() calls abort()/close(), _buffer becomes None, so the else: branch calls _maybe_resume_protocol() on a closed transport. Add if self._conn_lost: return after error_received().

  2. Two of three tests pass without the fix. Only _in_flight on Proactor fails on main; _from_callback and _reentrant_sendto don't exercise the change.

Comment thread Lib/asyncio/proactor_events.py Outdated
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
@graingert

graingert commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

the _reentrant_sendto is supposed to catch an error I introduced when I didn't have if self._write_fut is None:

@graingert

graingert commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

I can't add if self._conn_lost: return after error_received() otherwise it will never get to _loop_writing to call _call_connection_lost, see also #156920

except OSError as exc:
self._protocol.error_received(exc)
if self._buffer:
if self._buffer or self._closing:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kumaraditya303 this change doesn't make sense without the other changes from #156921

It would be easier if I could get that PR that fixes both issues reviewed in one go

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.

_ProactorDatagramTransport never resumes a paused protocol after a write error

2 participants