New submission from Adam Meily:

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.

----------
components: asyncio
messages: 290010
nosy: Adam Meily, yselivanov
priority: normal
severity: normal
status: open
title: asyncio: Windows Proactor Event Loop UDP Support
type: enhancement
versions: Python 3.5

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29883>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to