uvloop icon indicating copy to clipboard operation
uvloop copied to clipboard

Failed to create_datagram_endpoint() with AF_UNIX family

Open ankogan opened this issue 4 years ago • 1 comments

  • uvloop version: 0.15.2
  • Python version: 3.7.3
  • Platform: Debian GNU/Linux 10
  • Can you reproduce the bug with PYTHONASYNCIODEBUG in env?:
  • Does uvloop behave differently from vanilla asyncio? How?: asyncio correctly creates datagram unix socket

Code, works correctly using default event loop:

res = await loop.create_datagram_endpoint(MyProto, local_addr='/tmp/my_unix_sock', family=socket.AF_UNIX)

Trace:

Traceback (most recent call last):
  File "/usr/lib/python3.7/asyncio/runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "uvloop/loop.pyx", line 1494, in uvloop.loop.Loop.run_until_complete
  File "./my_app.py", line 75, in main
    family = socket.AF_UNIX)
  File "uvloop/loop.pyx", line 3023, in create_datagram_endpoint
TypeError: local_addr must be a tuple of (host, port)

ankogan avatar Feb 25 '21 13:02 ankogan

I can confirm this issue and traced it to line 3057 below:

https://github.com/MagicStack/uvloop/blob/3e71ddc3383a8e0546519117c8775323c19eb6d7/uvloop/loop.pyx#L3049-L3060

Simply put it seems that uvloop will not accept creation of a AF_UNIX datagram socket without a predetermined remote address. Yet this would be a reasonable usecase if one planed to use the created socket with sendto.

As @ankogan correctly points out, the standard asyncio event loop supports this.

joell avatar Aug 13 '21 20:08 joell