[Python-ideas] The async API of the future

Sturla Molden sturla at molden.no
Sat Nov 3 00:21:43 CET 2012


Den 2. nov. 2012 kl. 23:14 skrev Antoine Pitrou <solipsis at pitrou.net>:

> On Fri, 2 Nov 2012 22:29:09 +0100
> Sturla Molden <sturla at molden.no> wrote:
>> 
>> IOCP might be the easiest way to get high performance on Windows, but certainly not the only.
>> 
>> IOCP is a simple user-space wrapper for a thread-pool and overlapped (i.e. asynchronous) i/o. There is nothing IOCP can do that cannot be done with a pool of threads and non-blocking read or write operations.
>> 
>> Windows certainly has a function to select among multiple wait objects, called WaitForMultipleObjects. If open files are associated with event objects signalling "ready-to-read" or "ready-to-write", that is the basic machinery of an Unix select() function.
> 
> Hmm, but the basic problem with WaitForMultipleObjects is that it has a
> hard limit of 64 objects you can wait on.
> 

Or a simpler solution than nesting them into a tree: Let the calls to WaitForMultipleObjects time out at once, and loop over as many events as you need, polling 64 event objects simultaneously. At the end of the loop, call Sleep(0) to avoid burning the CPU. A small number of threads could also be used to run this loop in parallel.

Sturla







> Regards
> 
> Antoine.
> 
> 
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas



More information about the Python-ideas mailing list