-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Upstream asyncio doesn't offer "high level" support for datagram connections, along the lines of StreamReader/StreamWriter: https://docs.python.org/3/library/asyncio-stream.html . Instead lower-level support is available: https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.AbstractEventLoop.create_datagram_endpoint , based on protocol/transports paradigm, which isn't part of uasyncio.
This raises a question what to do about UDP/datagram support in uasyncio. It might even work somehow now, I know that @peterhinch used it. Like, StreamReader.read() should be read a datagram packet, and likewise StreamWriter.awrite() should be able to send it, even though both were designed with stream connection in mind. That's still a bit hacky and might not work for various edge cases too. And there're still datagram-specific calls like recvfrom() and sendto().
Two obvious approaches are:
- Stuff more functions into StreamReader and StreamWriter, which then become misnomers, as they aren't intended for just streams any longer.
- Introduce separate class(es) for datagrams, then also duplicate open_connection()/start_server() calls.
Even these 2 choices keep the line of deviating from the upstream, then maybe also go even further:
- Somehow hack the API to avoid duplication of p.2.