Closed
Description
- uvloop version: 0.13.0
- Python version: 3.7.4
- Platform: Ubuntu
- Can you reproduce the bug with
PYTHONASYNCIODEBUG
in env?: Yes
The following code, using local_addr and remote_addr together:
import asyncio
try:
import uvloop
uvloop.install()
except ImportError:
uvloop = None
server_addr = ('127.0.0.1', 8888)
client_addr = ('127.0.0.1', 0)
async def run():
print(asyncio.get_event_loop())
server_transport, client_protocol = await asyncio.get_event_loop().create_datagram_endpoint(asyncio.DatagramProtocol,
local_addr=server_addr)
print('SERVER RUNNING')
client_transport, client_conn = await asyncio.get_event_loop().create_datagram_endpoint(asyncio.DatagramProtocol,
remote_addr=server_addr,
local_addr=client_addr)
client_transport.close()
print('CLIENT DONE')
server_transport.close()
print('SERVER STOPPED')
if __name__ == '__main__':
asyncio.run(run())
produces the following error:
<uvloop.Loop running=True closed=False debug=False>
Traceback (most recent call last):
File "scratch_144.py", line 35, in <module>
asyncio.run(run())
File "/usr/lib/python3.7/asyncio/runners.py", line 43, in run
return loop.run_until_complete(main)
File "uvloop/loop.pyx", line 1417, in uvloop.loop.Loop.run_until_complete
File "scratch_144.py", line 29, in run
await run_client()
File "scratch_144.py", line 20, in run_client
transport, conn = await asyncio.get_event_loop().create_datagram_endpoint(asyncio.DatagramProtocol, remote_addr=server_addr, local_addr=client_addr)
File "uvloop/loop.pyx", line 2980, in create_datagram_endpoint
File "uvloop/handles/udp.pyx", line 86, in uvloop.loop.UDPTransport._connect
OSError: [Errno 106] Transport endpoint is already connected
If I remove the local_addr argument from the second create_datagram_endpoint, it works.
The above example works ok in Selector and Proactor.