This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: asyncio SelectorEventLoop.sock_connect fails with a UDP socket
Type: Stage: resolved
Components: asyncio Versions: Python 3.11, Python 3.10, Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: asvetlov, graingert, miss-islington, yselivanov
Priority: normal Keywords: patch

Created on 2022-02-22 15:05 by graingert, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 31499 merged graingert, 2022-02-22 15:07
PR 31509 merged miss-islington, 2022-02-22 20:36
PR 31510 merged miss-islington, 2022-02-22 20:36
Messages (4)
msg413709 - (view) Author: Thomas Grainger (graingert) * Date: 2022-02-22 15:05
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
msg413742 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2022-02-22 20:36
New changeset 8fb94893e4a870ed3533e80c4bc2f1ebf1cfa9e7 by Thomas Grainger in branch 'main':
bpo-46827: pass sock.type to getaddrinfo in sock_connect (GH-31499)
https://github.com/python/cpython/commit/8fb94893e4a870ed3533e80c4bc2f1ebf1cfa9e7
msg413746 - (view) Author: miss-islington (miss-islington) Date: 2022-02-22 21:09
New changeset d327517b54c148eba499c777b99760356102cbe0 by Miss Islington (bot) in branch '3.10':
bpo-46827: pass sock.type to getaddrinfo in sock_connect (GH-31499)
https://github.com/python/cpython/commit/d327517b54c148eba499c777b99760356102cbe0
msg413747 - (view) Author: miss-islington (miss-islington) Date: 2022-02-22 21:10
New changeset 29e8c43b32d6f1ec2e8b4fd8c4903d30830f280f by Miss Islington (bot) in branch '3.9':
bpo-46827: pass sock.type to getaddrinfo in sock_connect (GH-31499)
https://github.com/python/cpython/commit/29e8c43b32d6f1ec2e8b4fd8c4903d30830f280f
History
Date User Action Args
2022-04-11 14:59:56adminsetgithub: 90983
2022-02-22 21:10:49asvetlovsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2022-02-22 21:10:08miss-islingtonsetmessages: + msg413747
2022-02-22 21:09:42miss-islingtonsetmessages: + msg413746
2022-02-22 20:36:25miss-islingtonsetpull_requests: + pull_request29637
2022-02-22 20:36:25asvetlovsetmessages: + msg413742
2022-02-22 20:36:20miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request29636
2022-02-22 15:07:13graingertsetkeywords: + patch
stage: patch review
pull_requests: + pull_request29629
2022-02-22 15:05:31graingertcreate