Skip to content

uvloop does not support original unix udp socketpair #304

Description

@ZhuYuJin
importasyncioimportos, socketimportuvloopasyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
try:
os.unlink("./tmp")
except:
passtry:
os.unlink("./tmp1")
except:
passsocket_pair=socket.socketpair(socket.AF_UNIX, socket.SOCK_DGRAM, 0)
classWorkerConnection(asyncio.Protocol):
def__init__(self):
print("init connection in worker")
self.aio_connection=Nonedefconnection_made(self, transport):
self.aio_connection=transportdefdatagram_received(self, data: bytes, addr):
print(data)
classDispatcherConnection(asyncio.Protocol):
def__init__(self):
print("init connection in dispatcher")
self.aio_connection=Nonedefconnection_made(self, transport):
self.aio_connection=transportdefdatagram_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.

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