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.

Author meilyadam
Recipients meilyadam, yselivanov
Date 2017-03-22.19:28:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I am working on a Python 3.5 project that uses asyncio on a Windows system to poll both UDP and TCP connections. Multiple sources online say that the Windows Proactor event loop, which uses I/O Completion Ports, is considerably faster and more efficient than the default Selector event loop. I'm using both UDP and TCP connections so I am stuck with the Selector event loop for the time being. I've seen the overhead of 128 open UDP/TCP connections on the Selector event loop to be near 85%, which I understand is entirely spent in Windows proprietary code and not the Python implementation.

I'd like to take a shot at implementing UDP support in the IOCP event loop. It looks like there will be a considerable amount of code shared between TCP and UDP IOCP so I plan on implementing UDP support directly in _ProactorReadPipeTransport and _ProactorBaseWritePipeTransport. I should be able to do this by wrapping any TCP/UDP specific function calls in a check of:

if sock.type == socket.SOCK_DGRAM:
    # Do UDP stuff
elif sock.type == socket.SOCK_STREAM:
    # Do TCP stuff

My initial implementation plan is to:

 - Call datagram_received() instead of data_received() when UDP data is available in _ProactorReadPipeTransport._loop_reading().
 - Implement BaseProactorEventLoop._make_datagram_transport().
 - Implement wrappers for WSAConnect, WSARecvFrom, and WSASendTo in _overlapped.
 - Implement sendto() and recvfrom() in IocpProactor, which will use the new functions in _overlapped.
 - Implement handling for UDP "connections" in IocpProactor.connect() to call WSAConnect(). WSAConnect() appears to always return immediately so the function not supporting IOCP shouldn't be an issue. We can't use ConnectEx() for UDP because ConnectEx() is for connection-oriented sockets only.

My project is unfortunately tied to Python 3.5. So, if possible, I'd like to have UDP support merged into a v3.5 release. I can fork off of master instead of v3.5.3 if Python 3.5 support isn't an option.
Date User Action Args
2017-03-22 19:28:01meilyadamsetrecipients: + meilyadam, yselivanov
2017-03-22 19:28:01meilyadamsetmessageid: <>
2017-03-22 19:28:01meilyadamlinkissue29883 messages
2017-03-22 19:28:00meilyadamcreate