[Python-Dev] Twisted Isn't Specific (was Re: Trial balloon: microthreads library in stdlib)

Phillip J. Eby pje at telecommunity.com
Thu Feb 15 05:21:08 CET 2007


At 04:25 PM 2/15/2007 +1300, Greg Ewing wrote:
>Phillip J. Eby wrote:
>>peak.events, for example, lets you have multiple event loops running in 
>>the same or different threads.
>
>Different threads is okay if you're willing to use threads,
>but you might not. The reason you're using an event loop
>may well be precisely so that you *don't* have to use
>threads.
>
>And... how do you run multiple event loops simultaneously
>in the *same* thread?

When one is nested inside the other.  This isn't a common need, but it's 
occasionally useful if you need to switch back and forth between blocking 
and non-blocking code.  For example, suppose that you have some code that 
wants to offer a synchronous interface to an asynchronous library...  and 
the synchronous code is being called from a FastCGI "accept" event 
loop.  The inner code can't use the outer event loop, because the outer 
loop isn't going to proceed until the inner code is finished.



More information about the Python-Dev mailing list