python
runtime_error
ai_generated
true
NotImplementedError: Datagram endpoints are not supported on this event loop
ID: python/asyncio-datagram-endpoint-not-supported
80%Fix Rate
84%Confidence
0Evidence
2024-10-22First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.8+ | active | — | — | — |
| 3.9+ | active | — | — | — |
| 3.10+ | active | — | — | — |
| 3.11+ | active | — | — | — |
| 3.12+ | active | — | — | — |
Root Cause
create_datagram_endpoint() was called on a ProactorEventLoop (Windows default), which does not support UDP datagrams.
generic中文
在 ProactorEventLoop(Windows 默认)上调用了 create_datagram_endpoint(),它不支持 UDP 数据报。
Workarounds
-
95% success
import asyncio, sys if sys.platform == 'win32': asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) asyncio.run(main()) -
90% success
import uvloop uvloop.install() asyncio.run(main())
Dead Ends
Common approaches that don't work:
-
95% fail
The loop type does not change; retry raises the same error.
-
70% fail
Loses async semantics and does not integrate with the loop's datagram protocol.