Repository navigation
Add low level UDP socket functions to asyncio #90961
Description
Activity
The asyncio module currently has a number of low-level functions for working asynchronously with raw socket objects. Such functions for working with UDP sockets are, however, notably absent, and there is no workaround for this. You can of course use sock_receive() with UDP sockets but that would discard the sender address which is a showstopper problem. Also, having a send function that applies back pressure to the sender if the kernel buffer is full would also be prudent.
I will provide a PR if you're okay with this.
It would include the following functions:- sock_sendto()
- sock_recvfrom()
- sock_recvfrom_into()
- added3.11only security fixesonly security fixestype-featureA feature request or enhancementA feature request or enhancement
on Feb 20, 2022 One question: should I add the "flags" argument to the new functions? For some reason it's missing from the existing functions, so maybe I should add that in a separate PR?
A separate issue for 'flags' adding looks better. The reason for missing is an oversight I think.
Sorry, I was not clear maybe.
Newly added methods can have aflagargument from the very beginning.
Adding a flag to already existing methods requires a separate issue.Yeah, my question was specific about the new functions, so I understood that a separate PR should add that to the all the relevant functions.
I have a different problem now however: the test suite is failing in CI but not locally. It's giving me NameError about a function used by existing tests but for some reason, it's not defined in the scope of the new test functions?!?
The proactor version of sock_recvfrom_into() is giving me quite a bit of trouble, as it seems to require heavy handed changes in _overlapped.c.
I'm also not very successful in testing cases where sendto() would fill the kernel buffer and raise BlockingIOError. With TCP this is easy but with UDP near impossible to do in a controlled fashion in the test suite.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields: