-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
WinError 10022 for create_datagram_endpoint with local_addr=None. #119711
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Maybe @zooba had any insight to share here? |
No insights in particular.
What should be happening here with a local address of |
Well, that's indeed the question, if something should be changed (or not) in this case. The uvloop test case mentioned above is a rather extreme case, so one option (i) is to ignore this problem (asyncio does not have a test case with Indeed, another option (ii) is to assign a default address if Or option (iii), I'm not sure about people's preferences here (my preference is option (ii)). My report was to highlight this difference between the event loops, which is good to document I think, as ultimately we like these loops to be substitutes for one another. |
Since It is clearly intended to have the semantics that the socket is not bound in this case. The UNIX stack has clear semantics for this. (Although I'm not sure what they are -- I'm sure UNIX references like the Stevens books spell it out. But presumably it lets the kernel decide what to do.) If the Proactor event loop doesn't support this, we should just document that -- picking one of the possible local addresses and binding to it seems inconsistent, since the library has no way to know which address the caller meant, and the UNIX semantics are different. |
Yeah, you're right, asyncio actually has quite a few tests that have Nevertheless, this problem does not arise in practice, so just documenting that the proactor event loop does not support this sounds fine. |
Cool. Do you feel confident contributing a small docs PR? |
Happy to consider that. Not sure about the audience for such a note though and where it would fit. The doc for |
I’d add a note to the public API docs for that function. |
Bug report
Bug description:
A problem occurs with the Windows proactor event loop when creating a datagram endpoint with
local_addr=None
. The problem does not occur with the selector event loop (either on Windows or Linux).gives as output
The problem happens because the socket
conn
is not bound whenWSARecvFrom
is called. Thebind()
call is skipped because the local address wasNone
, see:cpython/Lib/asyncio/base_events.py
Lines 1440 to 1441 in 86d1a1a
The code above is a stripped down version of the following uvloop test case:
https://github.com/MagicStack/uvloop/blob/6c770dc3fbdd281d15c2ad46588c139696f9269c/tests/test_udp.py#L141-L160
This test passes on Linux both with the uvloop and with the asyncio (selector) loop.
CPython versions tested on:
3.8, 3.9, 3.10, 3.11, 3.12, 3.13
Operating systems tested on:
Windows
The text was updated successfully, but these errors were encountered: