[Python-ideas] An alternate approach to async IO

Sturla Molden sturla at molden.no
Tue Nov 27 22:25:55 CET 2012


Den 27. nov. 2012 kl. 21:54 skrev Antoine Pitrou <solipsis at pitrou.net>:

> 
> You don't need to acquire the GIL if you use the Py_buffer API in the
> right way. You'll figure out the details :-)
> 

And if he don't, this is what Cython's memoryview syntax will help him to do :-)

As for the rest of his idea, I think it is fundamentally flawed in two ways:

First, there is no fundamental difference between a non-registered thread and a Python thread that has released the GIL. They are both native OS threads running freely without bothering the interpreter. So given that the GIL will br released in an extension module, a list of threading.Thread is much easier to set up than use POSIX or Windows threads from C.

Second, using a thread pool to monitor another thread pool (an IOCP on Windows) seems a bit confused. IOCPs can fire a callback function on completion. It is easier to let the IOCP use the simplified GIL API from the callback code to acquire the GIL, and notify the Python code with a callback. Or en even simpler solution is to use twisted (twistedmatrix.org) instead of reinventing the wheel. 


Sturla









More information about the Python-ideas mailing list