Created
July 29, 2020 12:19
-
-
Save agronholm/c0905c924629774d3d712ac43ff97c52 to your computer and use it in GitHub Desktop.
Reproduction script for asyncio udp bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import socket | |
class DatagramProtocol(asyncio.DatagramProtocol): | |
def error_received(self, exc: Exception) -> None: | |
print('received error:', exc.__class__, ':', exc) | |
async def main(): | |
loop = asyncio.get_running_loop() | |
for family in socket.AF_INET, socket.AF_INET6: | |
for local_addr in ('', 0), None: | |
transport, protocol = await loop.create_datagram_endpoint( | |
DatagramProtocol, local_addr=local_addr, family=family) | |
print('family:', family, 'bound address:', transport.get_extra_info('sockname')) | |
transport.close() | |
for policy in asyncio.WindowsSelectorEventLoopPolicy(), asyncio.WindowsProactorEventLoopPolicy(): | |
print('policy:', policy.__class__.__name__) | |
asyncio.set_event_loop_policy(policy) | |
asyncio.run(main()) | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment