[Python-ideas] The async API of the future

Richard Oudkerk shibturn at gmail.com
Sat Nov 3 22:20:18 CET 2012

On 02/11/2012 11:59pm, Guido van Rossum wrote:
> Working code or it didn't happen. (And it should scale too.)

I have some (mostly) working code which replaces tulip's "pollster" 
classes with "proactor" classes for select(), poll(), epoll() and IOCP.  See


The IOCP proactor does not support ssl (or ipv6) so main.py does not 
succeed in downloading from xkcd.com using ssl.  Using the other 
proactors it works correctly.

The basic interface for the proactor looks like

     class Proactor:
         def recv(self, sock, n): ...
         def send(self, sock, buf): ...
         def connect(self, sock, address): ...
         def accept(self, sock): ...

         def poll(self, timeout=None): ...
         def pollable(self): ...

recv(), send(), connect() and accept() initiate io operations and return 
futures.  poll() returns a list of ready futures.  pollable() returns 
true if there are any outstanding operations registered with the 
proactor.  You use a pattern like

     f = proactor.recv(sock, 100)
     if not f.done():
         yield from scheduling.block_future(f)
     res = f.result()


More information about the Python-ideas mailing list