[issue11117] Implementing Async IO

David Beazley report at bugs.python.org
Sat Feb 5 15:54:42 CET 2011


David Beazley <dave at dabeaz.com> added the comment:

Glad you liked it!   I think there is a bit of a cautionary tale in there though. With aio_, there is the promise of better performance, but you're also going to need a *LOT* of advance planning and thought to avoid creating a tangled coding nightmare with it.

Just as an aside, one of the uses of aio_ related functions is to implement parts of user-level thread libraries in C (e.g., pthreads, etc.). A library might use the asynchronous I/O callbacks as part of implementing non-kernel (green) threads.  The code for doing this tends to be very low level and hairy with lots of signal handling--for example, if you want to context-switch between two user-level threads in C, you usually do it inside a signal handler (i.e., you thread-switch inside the signal handler called in response to aio_ completions). 

Whether it's feasible to expose aio_* all the way up to Python or not is an open question. I suspect it will be fraught with lots of tricky issues. In the end, it might just be easier to use threads.  Nevertheless, you'll learn a lot about Python internals by working on this :-).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11117>
_______________________________________


More information about the Python-bugs-list mailing list