Skip to content

Add low level UDP socket functions to asyncio #90961

Description

@agronholm
mannequin
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']

    Activity

    1. agronholm commented on Feb 20, 2022

      agronholmmannequin
      MannequinAuthor

      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()
    2. agronholm commented on Feb 20, 2022

      agronholmmannequin
      MannequinAuthor

      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?

    3. asvetlov commented on Feb 20, 2022

      @asvetlov
      Contributor

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

    4. asvetlov commented on Feb 20, 2022

      @asvetlov
      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.

    5. agronholm commented on Feb 20, 2022

      agronholmmannequin
      MannequinAuthor

      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.

    6. asvetlov commented on Mar 13, 2022

      @asvetlov
      Contributor

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

    7. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions