Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asyncio: create_datagram_endpoint() does not return a DatagramTransport #89049

Closed
ThomasTrummer mannequin opened this issue Aug 11, 2021 · 1 comment
Closed

asyncio: create_datagram_endpoint() does not return a DatagramTransport #89049

ThomasTrummer mannequin opened this issue Aug 11, 2021 · 1 comment
Assignees
Labels
3.9 only security fixes 3.10 only security fixes 3.11 only security fixes topic-asyncio

Comments

@ThomasTrummer
Copy link
Mannequin

ThomasTrummer mannequin commented Aug 11, 2021

BPO 44886
Nosy @asvetlov, @1st1, @miss-islington
PRs
  • bpo-44886: Inherit asyncio proactor datagram transport from asyncio.DatagramTransport #31512
  • [3.10] bpo-44886: Inherit asyncio proactor datagram transport from asyncio.DatagramTransport (GH-31512) #31514
  • [3.9] bpo-44886: Inherit asyncio proactor datagram transport from asyncio.DatagramTransport (GH-31512) #31515
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/asvetlov'
    closed_at = <Date 2022-02-24.10:09:09.089>
    created_at = <Date 2021-08-11.08:38:49.198>
    labels = ['3.11', '3.9', '3.10', 'expert-asyncio']
    title = 'asyncio: create_datagram_endpoint() does not return a DatagramTransport'
    updated_at = <Date 2022-03-13.23:58:06.656>
    user = 'https://bugs.python.org/ThomasTrummer'

    bugs.python.org fields:

    activity = <Date 2022-03-13.23:58:06.656>
    actor = 'asvetlov'
    assignee = 'asvetlov'
    closed = True
    closed_date = <Date 2022-02-24.10:09:09.089>
    closer = 'asvetlov'
    components = ['asyncio']
    creation = <Date 2021-08-11.08:38:49.198>
    creator = 'Thomas Trummer'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 44886
    keywords = ['patch']
    message_count = 1.0
    messages = ['399376']
    nosy_count = 4.0
    nosy_names = ['asvetlov', 'yselivanov', 'miss-islington', 'Thomas Trummer']
    pr_nums = ['31512', '31514', '31515']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'patch review'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue44886'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    @ThomasTrummer
    Copy link
    Mannequin Author

    ThomasTrummer mannequin commented Aug 11, 2021

    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())

    @ThomasTrummer ThomasTrummer mannequin added 3.8 only security fixes 3.9 only security fixes topic-asyncio labels Aug 11, 2021
    @asvetlov asvetlov added 3.10 only security fixes 3.11 only security fixes and removed 3.8 only security fixes labels Feb 22, 2022
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes 3.10 only security fixes 3.11 only security fixes topic-asyncio
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant