Skip to content

UVLoop raises "requires a DNS lookup" on Unix Domain Sockets #196

@pax0r

Description

@pax0r
  • uvloop version: 0.11.2
  • Python version: 3.7
  • Platform: Debian 9.5
  • Can you reproduce the bug with PYTHONASYNCIODEBUG in env?: yes

When using uvloop with Unix Domain Sockets uvloop.loop.UDPTransport.sendto raises ValueError: UDP.sendto(): address '(socket path)' requires a DNS lookup which is wrong, as there are no DNS lookups for Unix Domain Sockets.

Original Python aioloop works without any problems with this.

I think this can be related to #91

Code to reproduce:

import asyncio
import os
import random
import socket
import string

import uvloop


asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())


def create_sock(path):
    try:
        os.unlink(path)
    except FileNotFoundError:
        pass
    s = socket.socket(socket.AF_UNIX, type=socket.SOCK_DGRAM)
    s.bind(path)
    return s


async def main():
    # Get a reference to the event loop as we plan to use
    # low-level APIs.
    loop = asyncio.get_running_loop()

    message = "Hello World!"
    filename = '/tmp/{}'.format(''.join(random.choice(string.ascii_letters) for i in range(30)))
    sock = create_sock(filename)

    transport, protocol = await loop.create_datagram_endpoint(
        lambda: asyncio.DatagramProtocol(),
        sock=sock)

    transport.sendto(message.encode(), filename)

asyncio.run(main())

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions