[Python-ideas] async: feedback on EventLoop API

Richard Oudkerk shibturn at gmail.com
Tue Dec 18 20:41:55 CET 2012


On 18/12/2012 4:59pm, Guido van Rossum wrote:
> On Mon, Dec 17, 2012 at 11:26 PM, Geert Jansen <geertj at gmail.com> wrote:
>> I needed a self-pipe on Windows before. See below. With this, the
>> select() based loop might work unmodified on Windows.
>>
>> https://gist.github.com/4325783
>
> Thanks! Before I paste this into Tulip, is there any kind of copyright on this?
>
>> Of course it wouldn't be as efficient as an IOCP based loop.
>
> The socket loop is definitely handy on Windows in a pinch. I have
> plans for an IOCP-based loop based on Richard Oudkerk's 'proactor'
> branch of Tulip v1, but I don't have a Windows machine to test it on
> ATM (hopefully that'll change once I am actually at Dropbox).
>

polling.py in the proactor branch already had an implementation of 
socketpair() for Windows;-)

Also note that on Windows a connecting socket needs to be added to wfds 
*and* xfds when you do

     ... = select(rfds, wfds, xfds, timeout)

If the connection fails then the handle is reported as being exceptional 
but *not* writable.

It might make sense to have add_connector()/remove_connector() which on 
Unix is just an alias for add_writer()/remove_writer().  This would be 
useful if tulip ever has a loop based on WSAPoll() for Windows (Vista 
and later), since WSAPoll() has an awkward bug concerning asynchronous 
connects.

-- 
Richard




More information about the Python-ideas mailing list