René's URL Explorer Experiment


Title: `_ProactorDatagramTransport` never resumes a paused protocol after a write error · Issue #156698 · python/cpython · GitHub

Open Graph Title: `_ProactorDatagramTransport` never resumes a paused protocol after a write error · Issue #156698 · python/cpython

X Title: `_ProactorDatagramTransport` never resumes a paused protocol after a write error · Issue #156698 · python/cpython

Description: Bug report Bug description: On ProactorEventLoop, if a UDP write fails synchronously or asynchronously while the write buffer is non-empty, _loop_writing() reports the error via error_received() and just returns. It doesn't re-arm the wr...

Open Graph Description: Bug report Bug description: On ProactorEventLoop, if a UDP write fails synchronously or asynchronously while the write buffer is non-empty, _loop_writing() reports the error via error_received() an...

X Description: Bug report Bug description: On ProactorEventLoop, if a UDP write fails synchronously or asynchronously while the write buffer is non-empty, _loop_writing() reports the error via error_received() an...

Opengraph URL: https://github.com/python/cpython/issues/156698

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`_ProactorDatagramTransport` never resumes a paused protocol after a write error","articleBody":"# Bug report\n\n### Bug description:\n\nOn `ProactorEventLoop`, if a UDP write fails synchronously or asynchronously while the\nwrite buffer is non-empty, `_loop_writing()` reports the error via `error_received()`\nand just returns. It doesn't re-arm the write loop and doesn't call\n`_maybe_resume_protocol()`. If the protocol was paused at that point, it stays paused\nforever anything left in `self._buffer` is stranded, and a well-behaved protocol that\nrespects `pause_writing()` will never call `sendto()` again to un-stick it. Lost wakeup.\n\n```python\n# Lib/asyncio/proactor_events.py, _ProactorDatagramTransport._loop_writing\n        except OSError as exc:\n            self._protocol.error_received(exc)\n        except Exception as exc:\n            self._fatal_error(exc, 'Fatal write error on datagram transport')\n        else:\n            self._write_fut.add_done_callback(self._loop_writing)\n            self._maybe_resume_protocol()\n```\n\n`_SelectorDatagramTransport._sendto_ready()` has the identical structure on `OSError`, but it's\nharmless there the fd is still registered with `add_writer()`, so the loop calls it\nagain next iteration and drains the buffer anyway. The proactor has no equivalent\nre-trigger, so the same code is self-healing on selectors and terminal on IOCP.\n\n### Reproducer\n\nAttached: `proactor_datagram_write_pause.py`. Gives a deterministic write failure, and `set_write_buffer_limits(0)` makes the\npause deterministic.\n\nConfirmed on Windows, both 3.10.11 and 3.14.7:\n\n```\nfail-in-flight:\n    events   = ['pause_writing', 'error_received([WinError 1784] ...)']\n    buffered = 6\n    verdict  = STRANDED\n```\n\n`pause_writing` fires, the write fails, and `resume_writing` never comes the protocol\nsits paused with data stuck in the buffer until something outside asyncio forces another\n`sendto()`.\n\nLinux (3.12.3, selector loop) is fine, as expected: the buffer never has a chance to fill\nin the first place, so `pause_writing` never fires.\n\n### Suggested fix\n\n```python\n        except OSError as exc:\n            self._protocol.error_received(exc)\n            if self._buffer and not self._conn_lost:\n                self._loop.call_soon(self._loop_writing)\n            else:\n                self._maybe_resume_protocol()\n```\n\n### Related\n\n- gh-91227 / gh-32011 the read-side twin of this, fixed in 3.12 by swallowing\n  `ERROR_PORT_UNREACHABLE` in `IocpProactor._finish_recvfrom` (not backported to 3.11)\n- gh-88906 closed by the above\n- gh-127057 (open) `WSARecvFrom` raising `ConnectionResetError` synchronously still\n  kills `_loop_reading()` the same way, on all versions\n\n### Your environment\n\n- CPython versions tested: 3.10.11, 3.14.7\n- OS: Windows 11, `ProactorEventLoop\n\nhere's the reproducer:\n```py\n\"\"\"\nDoes _ProactorDatagramTransport._loop_writing() strand a paused protocol?\n\nRun on Windows (ProactorEventLoop).  See README.md for what the output means.\n\"\"\"\n\nfrom __future__ import annotations\n\nimport asyncio\nimport sys\n\nOVERSIZED = b\"\\x00\" * 70000  # guaranteed oversend error (WSAEMSGSIZE or, on some\n# builds, WinError 1784 ERROR_INVALID_USER_BUFFER); either way it fails the write\n\n\nclass Protocol(asyncio.DatagramProtocol):\n    def connection_made(self, transport: asyncio.DatagramTransport) -> None:\n        self.transport = transport\n        self.events: list[str] = []\n        self.error = asyncio.get_running_loop().create_future()\n        # a high water mark of 0 makes the pause deterministic; it is what\n        # anyio's UDP sockets use\n        transport.set_write_buffer_limits(0)\n\n    def datagram_received(self, data: bytes, addr: object) -> None:\n        self.events.append(f\"datagram_received({len(data)} bytes)\")\n\n    def pause_writing(self) -> None:\n        self.events.append(\"pause_writing\")\n\n    def resume_writing(self) -> None:\n        self.events.append(\"resume_writing\")\n\n    def error_received(self, exc: Exception) -> None:\n        self.events.append(f\"error_received({exc})\")\n        if not self.error.done():\n            self.error.set_result(exc)\n\n\nasync def scenario(name: str, first: bytes, second: bytes) -> None:\n    loop = asyncio.get_running_loop()\n    transport, protocol = await loop.create_datagram_endpoint(\n        Protocol, local_addr=(\"127.0.0.1\", 0)\n    )\n    addr = transport.get_extra_info(\"sockname\")\n\n    # the first sendto() arms the overlapped write, so the second one has to be\n    # buffered behind it, which trips pause_writing() at a high water mark of 0\n    transport.sendto(first, addr)\n    transport.sendto(second, addr)\n\n    try:\n        await asyncio.wait_for(protocol.error, 5)\n    except asyncio.TimeoutError:\n        protocol.events.append(\"\u003cno error reported>\")\n\n    await asyncio.sleep(0.5)\n    paused = \"pause_writing\" in protocol.events\n    resumed = \"resume_writing\" in protocol.events\n    buffered = transport.get_write_buffer_size()\n    print(f\"{name}:\")\n    print(f\"    events   = {protocol.events}\")\n    print(f\"    buffered = {buffered}\")\n    print(f\"    verdict  = {'STRANDED' if paused and not resumed else 'ok'}\")\n\n    # recovery probe: an application send is the only thing that can re-arm the\n    # write loop, which a protocol honouring pause_writing() would never do\n    if paused and not resumed:\n        transport.sendto(b\"probe\", addr)\n        await asyncio.sleep(0.5)\n        print(f\"    after an unsolicited sendto(): {protocol.events}\")\n\n    transport.close()\n    await asyncio.sleep(0.1)\n\n\nasync def main() -> None:\n    print(sys.version)\n    print(type(asyncio.get_running_loop()).__name__)\n    print()\n    # covers WSAEMSGSIZE being reported at completion of the in-flight write\n    await scenario(\"fail-in-flight\", OVERSIZED, b\"queued\")\n    # covers WSAEMSGSIZE being reported synchronously by WSASendTo, from the\n    # completion callback of the preceding write\n    await scenario(\"fail-from-callback\", b\"ok\", OVERSIZED)\n\n\n```\n\n### CPython versions tested on:\n\n3.14\n\n### Operating systems tested on:\n\nWindows\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-156718\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/graingert","@type":"Person","name":"graingert"},"datePublished":"2026-08-31T10:28:12Z","url":"https://github.com/python/cpython/issues/156698"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:d90aee83-a155-d902-ded3-87825f0ee2fd
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idBCE8:24645:155D1A1:1C310E9:6B01FA70
html-safe-nonce3f05f3814daea7b4cb47eba7e3581aebd4dd0d434e032e94c2b179f7a81bfde7
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQ0U4OjI0NjQ1OjE1NUQxQTE6MUMzMTBFOTo2QjAxRkE3MCIsInZpc2l0b3JfaWQiOiIyNjQ3MzIwOTE4NTIyNzIyOTI4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac94f7f9276bc5116e39a1def13135bbebc1145b30d113b362598974a4dde39a72
hovercard-subject-tagissue:5299112555
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/156698/issue_layout
twitter:imagehttps://opengraph.githubassets.com/7e8b8fd0d7102bb4859f1877b36c1b2953e8896d9c0100802ecbc192f948b533/python/cpython/issues/156698
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/7e8b8fd0d7102bb4859f1877b36c1b2953e8896d9c0100802ecbc192f948b533/python/cpython/issues/156698
og:image:altBug report Bug description: On ProactorEventLoop, if a UDP write fails synchronously or asynchronously while the write buffer is non-empty, _loop_writing() reports the error via error_received() an...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamegraingert
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
turbo-cache-controlno-preview
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetcanary-2
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/cpython/issues/156698#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F156698
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F156698
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/156698
Reloadhttps://github.com/python/cpython/issues/156698
Reloadhttps://github.com/python/cpython/issues/156698
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.4k (2.4k)https://github.com/python/cpython/pulls
Actionshttps://github.com/python/cpython/actions
Projectshttps://github.com/python/cpython/projects
Security and qualityhttps://github.com/python/cpython/security
Insightshttps://github.com/python/cpython/insights
https://github.com/python/cpython
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/156698
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/156698
_ProactorDatagramTransport never resumes a paused protocol after a write errorhttps://github.com/python/cpython/issues/156698#top
OS-windowshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22OS-windows%22
stdlibStandard Library Python modules in the Lib/ directoryhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22stdlib%22
topic-asynciohttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-asyncio%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com/graingert
graingerthttps://github.com/graingert
on Aug 31, 2026https://github.com/python/cpython/issues/156698#issue-5299112555
asyncio proactor udp transport stops responding after send to port that isn't listening #91227https://github.com/python/cpython/issues/91227
gh-91227: Ignore ERROR_PORT_UNREACHABLE #32011https://github.com/python/cpython/pull/32011
asyncio DatagramProtocol stops calling callbacks after OSError, on Windows #88906https://github.com/python/cpython/issues/88906
asyncio proactor udp transport stops responding after send to port that isn't listening due to ConnectionResetError from WSARecvFrom #127057https://github.com/python/cpython/issues/127057
gh-156698: Fix _ProactorDatagramTransport never resumes a paused protocol after a write error #156718https://github.com/python/cpython/pull/156718
graingerthttps://github.com/graingert
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
on Aug 31, 2026https://github.com/python/cpython/issues/156698#event-30272318066
aiskhttps://github.com/aisk
topic-asynciohttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-asyncio%22
OS-windowshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22OS-windows%22
stdlibStandard Library Python modules in the Lib/ directoryhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22stdlib%22
on Aug 31, 2026https://github.com/python/cpython/issues/156698#event-30274266495
github-project-automationhttps://github.com/apps/github-project-automation
asynciohttps://github.com/orgs/python/projects/29
on Aug 31, 2026https://github.com/python/cpython/issues/156698#event-30274269414
github-project-automationhttps://github.com/apps/github-project-automation
asynciohttps://github.com/orgs/python/projects/29
on Aug 31, 2026https://github.com/python/cpython/issues/156698
graingerthttps://github.com/graingert
on Aug 31, 2026https://github.com/python/cpython/issues/156698#event-30294944967
fix proactor error hanghttps://github.com/graingert/cpython/commit/800498e1ab516c4dc65eaddf216ebc75c6351a3e
https://docs.github.com/articles/closing-issues-via-commit-messages
800498ehttps://github.com/graingert/cpython/commit/800498e1ab516c4dc65eaddf216ebc75c6351a3e
fix proactor error hanghttps://github.com/graingert/cpython/commit/3006d6e730748931a023ad37ed887417c321d2d0
https://docs.github.com/articles/closing-issues-via-commit-messages
3006d6ehttps://github.com/graingert/cpython/commit/3006d6e730748931a023ad37ed887417c321d2d0
kumaraditya303https://github.com/kumaraditya303
on Sep 16, 2026https://github.com/python/cpython/issues/156698#event-31224064928
gh-156920, gh-156698: fix ProactorEventLoop datagram transport hangs …https://github.com/python/cpython/commit/7f52444d9b593413e6dd376f211dcbb58cc130f4
gh-156920https://github.com/python/cpython/issues/156920
gh-156698https://github.com/python/cpython/issues/156698
7f52444https://github.com/python/cpython/commit/7f52444d9b593413e6dd376f211dcbb58cc130f4
kumaraditya303https://github.com/kumaraditya303
completedhttps://github.com/python/cpython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Sep 16, 2026https://github.com/python/cpython/issues/156698#event-31224128953
github-project-automationhttps://github.com/apps/github-project-automation
asynciohttps://github.com/orgs/python/projects/29
on Sep 16, 2026https://github.com/python/cpython/issues/156698
Yhg1shttps://github.com/Yhg1s
on Sep 29, 2026https://github.com/python/cpython/issues/156698#event-32116268606
[3.13] gh-156920, gh-156698: fix ProactorEventLoop datagram transport…https://github.com/python/cpython/commit/0557ba8914237185b0efa112112747bbcc2a7bc7
gh-156920https://github.com/python/cpython/issues/156920
gh-156698https://github.com/python/cpython/issues/156698
0557ba8https://github.com/python/cpython/commit/0557ba8914237185b0efa112112747bbcc2a7bc7
encukouhttps://github.com/encukou
on Oct 12, 2026https://github.com/python/cpython/issues/156698#event-33043145247
[3.15] gh-156920, gh-156698: fix ProactorEventLoop datagram transport…https://github.com/python/cpython/commit/bbdef1f054bde457826e8e2a4abaa93f787549c8
gh-156920https://github.com/python/cpython/issues/156920
gh-156698https://github.com/python/cpython/issues/156698
bbdef1fhttps://github.com/python/cpython/commit/bbdef1f054bde457826e8e2a4abaa93f787549c8
[3.14] gh-156920, gh-156698: fix ProactorEventLoop datagram transport…https://github.com/python/cpython/commit/60067a6bbad9f5556106a807f7102b6a797129a2
gh-156920https://github.com/python/cpython/issues/156920
gh-156698https://github.com/python/cpython/issues/156698
60067a6https://github.com/python/cpython/commit/60067a6bbad9f5556106a807f7102b6a797129a2
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/156698
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/156698
OS-windowshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22OS-windows%22
stdlibStandard Library Python modules in the Lib/ directoryhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22stdlib%22
topic-asynciohttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-asyncio%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
asynciohttps://github.com/orgs/python/projects/29
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.