New submission from Thomas Trummer <th.trum...@gmail.com>:
According to the documentation[1] loop.create_datagram_endpoint() returns an asyncio.DatagramTransport. However on Windows this is not the case when the ProactorEventLoop is used (which seems to be the default since Python 3.8). This is a problem because a DatagramProtocol subclass needs a downcast in order to satisfy the type system (or mypy for that matter). [1] https://docs.python.org/3/library/asyncio-protocol.html#asyncio.DatagramTransport --- # Will print: <class 'asyncio.proactor_events._ProactorDatagramTransport'> False import asyncio class EchoServerProtocol(asyncio.DatagramProtocol): def connection_made(self, transport): print(type(transport), isinstance(transport, asyncio.DatagramTransport)) async def main(): transport, protocol = await asyncio.get_running_loop().create_datagram_endpoint( lambda: EchoServerProtocol(), local_addr=('127.0.0.1', 9999)) try: await asyncio.sleep(5) finally: transport.close() asyncio.run(main()) ---------- components: asyncio messages: 399376 nosy: Thomas Trummer, asvetlov, yselivanov priority: normal severity: normal status: open title: asyncio: create_datagram_endpoint() does not return a DatagramTransport versions: Python 3.8, Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue44886> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com