Skip to content

uvloop does not support original unix udp socketpair #304

Description

@ZhuYuJin
import asyncio
import os, socket
import uvloop
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())

try:
    os.unlink("./tmp")
except:
    pass
try:
    os.unlink("./tmp1")
except:
    pass

socket_pair = socket.socketpair(socket.AF_UNIX, socket.SOCK_DGRAM, 0)

class WorkerConnection(asyncio.Protocol):
    def __init__(self):
        print("init connection in worker")
        self.aio_connection = None

    def connection_made(self, transport):
        self.aio_connection = transport

    def datagram_received(self, data: bytes, addr):
    	print(data)

class DispatcherConnection(asyncio.Protocol):
    def __init__(self):
        print("init connection in dispatcher")
        self.aio_connection = None

    def connection_made(self, transport):
        self.aio_connection = transport

    def datagram_received(self, data: bytes, addr):
    	print(data)

loop = uvloop.new_event_loop()
asyncio.set_event_loop(loop)

coros = loop.create_datagram_endpoint(WorkerConnection, sock=socket_pair[0])
(transport1, protocol1) = loop.run_until_complete(coros)

coros = loop.create_datagram_endpoint(DispatcherConnection, sock=socket_pair[1])
(transport2, protocol2) = loop.run_until_complete(coros)

transport1.sendto(b'transport1')
transport2.sendto(b'transport2')

loop.run_forever()

I initialize a unix udp socketpair, and try to use uvloop to manage both sockets.
The code above has the following err:
image

However, when I bind address to both sockets, the err disappears.

socket_pair[0].bind("./tmp")
socket_pair[1].bind("./tmp1")

It shows uvloop does not support the original unix udp socketpair.

Activity

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions