This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: asyncio: create_datagram_endpoint() does not return a DatagramTransport
Type: Stage: patch review
Components: asyncio Versions: Python 3.11, Python 3.10, Python 3.9
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: asvetlov Nosy List: Thomas Trummer, asvetlov, miss-islington, yselivanov
Priority: normal Keywords: patch

Created on 2021-08-11 08:38 by Thomas Trummer, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 31512 merged asvetlov, 2022-02-22 22:58
PR 31514 merged miss-islington, 2022-02-22 23:40
PR 31515 merged miss-islington, 2022-02-22 23:41
Messages (1)
msg399376 - (view) Author: Thomas Trummer (Thomas Trummer) Date: 2021-08-11 08:38
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).



# 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=('', 9999))

        await asyncio.sleep(5)
Date User Action Args
2022-04-11 14:59:48adminsetgithub: 89049
2022-03-13 23:58:06asvetlovsetstage: resolved -> patch review
2022-02-24 10:09:09asvetlovsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2022-02-22 23:41:11miss-islingtonsetpull_requests: + pull_request29642
2022-02-22 23:40:33miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request29641
2022-02-22 22:59:31asvetlovsetassignee: asvetlov
2022-02-22 22:58:40asvetlovsetversions: + Python 3.10, Python 3.11, - Python 3.8
2022-02-22 22:58:10asvetlovsetkeywords: + patch
stage: patch review
pull_requests: + pull_request29639
2021-08-11 08:38:49Thomas Trummercreate