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

asyncio SelectorEventLoop.sock_connect fails with a UDP socket #90983

Closed
graingert mannequin opened this issue Feb 22, 2022 · 4 comments
Closed

asyncio SelectorEventLoop.sock_connect fails with a UDP socket #90983

graingert mannequin opened this issue Feb 22, 2022 · 4 comments
Labels
3.9 only security fixes 3.10 only security fixes 3.11 bug and security fixes topic-asyncio

Comments

@graingert
Copy link
Mannequin

graingert mannequin commented Feb 22, 2022

BPO 46827
Nosy @asvetlov, @1st1, @graingert, @miss-islington
PRs
  • bpo-46827: pass sock.type to getaddrinfo in sock_connect #31499
  • [3.10] bpo-46827: pass sock.type to getaddrinfo in sock_connect (GH-31499) #31509
  • [3.9] bpo-46827: pass sock.type to getaddrinfo in sock_connect (GH-31499) #31510
  • 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-02-22.21:10:49.763>
    created_at = <Date 2022-02-22.15:05:31.128>
    labels = ['3.11', '3.9', '3.10', 'expert-asyncio']
    title = 'asyncio SelectorEventLoop.sock_connect fails with a UDP socket'
    updated_at = <Date 2022-02-22.21:10:49.762>
    user = 'https://github.com/graingert'

    bugs.python.org fields:

    activity = <Date 2022-02-22.21:10:49.762>
    actor = 'asvetlov'
    assignee = 'none'
    closed = True
    closed_date = <Date 2022-02-22.21:10:49.763>
    closer = 'asvetlov'
    components = ['asyncio']
    creation = <Date 2022-02-22.15:05:31.128>
    creator = 'graingert'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 46827
    keywords = ['patch']
    message_count = 4.0
    messages = ['413709', '413742', '413746', '413747']
    nosy_count = 4.0
    nosy_names = ['asvetlov', 'yselivanov', 'graingert', 'miss-islington']
    pr_nums = ['31499', '31509', '31510']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue46827'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    @graingert
    Copy link
    Mannequin Author

    graingert mannequin commented Feb 22, 2022

    the following code:

    import socket
    import asyncio
    
    async def amain():
        with socket.socket(family=socket.AF_INET, proto=socket.IPPROTO_UDP, type=socket.SOCK_DGRAM) as sock:
            sock.setblocking(False)
            await asyncio.get_running_loop().sock_connect(sock, ("google.com", "443"))
    
    asyncio.run(amain())

    fails with:

    Traceback (most recent call last):
      File "/home/graingert/projects/test_foo.py", line 9, in <module>
        asyncio.run(amain())
      File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
        return loop.run_until_complete(main)
      File "/usr/lib/python3.10/asyncio/base_events.py", line 641, in run_until_complete
        return future.result()
      File "/home/graingert/projects/test_foo.py", line 7, in amain
        await asyncio.get_running_loop().sock_connect(sock, ("google.com", "443"))
      File "/usr/lib/python3.10/asyncio/selector_events.py", line 496, in sock_connect
        resolved = await self._ensure_resolved(
      File "/usr/lib/python3.10/asyncio/base_events.py", line 1395, in _ensure_resolved
        return await loop.getaddrinfo(host, port, family=family, type=type,
      File "/usr/lib/python3.10/asyncio/base_events.py", line 855, in getaddrinfo
        return await self.run_in_executor(
      File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run
        result = self.fn(*self.args, **self.kwargs)
      File "/usr/lib/python3.10/socket.py", line 955, in getaddrinfo
        for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
    socket.gaierror: [Errno -7] ai_socktype not supported

    @graingert graingert mannequin added 3.9 only security fixes 3.10 only security fixes 3.11 bug and security fixes topic-asyncio labels Feb 22, 2022
    @asvetlov
    Copy link
    Contributor

    New changeset 8fb9489 by Thomas Grainger in branch 'main':
    bpo-46827: pass sock.type to getaddrinfo in sock_connect (GH-31499)
    8fb9489

    @miss-islington
    Copy link
    Contributor

    New changeset d327517 by Miss Islington (bot) in branch '3.10':
    bpo-46827: pass sock.type to getaddrinfo in sock_connect (GH-31499)
    d327517

    @miss-islington
    Copy link
    Contributor

    New changeset 29e8c43 by Miss Islington (bot) in branch '3.9':
    bpo-46827: pass sock.type to getaddrinfo in sock_connect (GH-31499)
    29e8c43

    @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.9 only security fixes 3.10 only security fixes 3.11 bug and security fixes topic-asyncio
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants