Skip to content
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

Add low level UDP socket functions to asyncio #90961

Closed
agronholm mannequin opened this issue Feb 20, 2022 · 6 comments
Closed

Add low level UDP socket functions to asyncio #90961

agronholm mannequin opened this issue Feb 20, 2022 · 6 comments
Labels
3.11 only security fixes topic-asyncio type-feature A feature request or enhancement

Comments

@agronholm
Copy link
Mannequin

agronholm mannequin commented Feb 20, 2022

BPO 46805
Nosy @asvetlov, @agronholm, @1st1
PRs
  • bpo-46805: Add low level UDP socket functions to asyncio #31455
  • 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:

    assignee = None
    closed_at = <Date 2022-03-13.16:43:13.862>
    created_at = <Date 2022-02-20.10:27:09.534>
    labels = ['3.11', 'type-feature', 'expert-asyncio']
    title = 'Add low level UDP socket functions to asyncio'
    updated_at = <Date 2022-03-13.16:43:13.862>
    user = 'https://github.com/agronholm'

    bugs.python.org fields:

    activity = <Date 2022-03-13.16:43:13.862>
    actor = 'asvetlov'
    assignee = 'none'
    closed = True
    closed_date = <Date 2022-03-13.16:43:13.862>
    closer = 'asvetlov'
    components = ['asyncio']
    creation = <Date 2022-02-20.10:27:09.534>
    creator = 'alex.gronholm'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 46805
    keywords = ['patch']
    message_count = 6.0
    messages = ['413579', '413581', '413582', '413616', '413617', '415041']
    nosy_count = 3.0
    nosy_names = ['asvetlov', 'alex.gronholm', 'yselivanov']
    pr_nums = ['31455']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue46805'
    versions = ['Python 3.11']

    @agronholm
    Copy link
    Mannequin Author

    agronholm mannequin commented Feb 20, 2022

    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()

    @agronholm agronholm mannequin added 3.11 only security fixes topic-asyncio type-feature A feature request or enhancement labels Feb 20, 2022
    @agronholm
    Copy link
    Mannequin Author

    agronholm mannequin commented 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?

    @asvetlov
    Copy link
    Contributor

    A separate issue for 'flags' adding looks better. The reason for missing is an oversight I think.

    @asvetlov
    Copy link
    Contributor

    Sorry, I was not clear maybe.
    Newly added methods can have a flag argument from the very beginning.
    Adding a flag to already existing methods requires a separate issue.

    @agronholm
    Copy link
    Mannequin Author

    agronholm mannequin commented Feb 20, 2022

    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.

    @asvetlov
    Copy link
    Contributor

    New changeset 9f04ee5 by Alex Grönholm in branch 'main':
    bpo-46805: Add low level UDP socket functions to asyncio (GH-31455)
    9f04ee5

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.11 only security fixes topic-asyncio type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant