[Twisted-Python] Re: 3 questions about async, threading and dynamic protocol selection

Christopher Armstrong radix at twistedmatrix.com
Wed Apr 4 07:46:40 MDT 2007


On 4/4/07, Nicola Larosa <nico at teknico.net> wrote:
> > littlesweetmelon at gmail.com wrote:
> >> Twist requires all user functions to be non-blocked. If reactor calls
> >> a blocking function, what will happen? In my mind, reactor maintains a
> >> command queue internally (just like windows message queue). The
> >> blocking function only postpones the execution of other queued
> >> functions, but it does not break the logic of the program. Is that
> >> right?
>
> Yes, that's right. The processing of subsequent events will be delayed, but
> the program will still run correctly, *if* its correctness does not
> depend on the timing of event processing.

However, I want to stress that technically Twisted is not maintaining
a command queue relevant to this situation. Yes, it does have a queue
of scheduled calls, but when you're just talking about running some
code that blocks, it's not Twisted which is preventing further things
from happening, it is the sequential nature of the code itself.
There's no need to queue things up when Python itself, when executing
"a(); b()", prevents 'b' from executing before 'a' has returned.


-- 
Christopher Armstrong
International Man of Twistery
http://radix.twistedmatrix.com/
http://twistedmatrix.com/
http://canonical.com/




More information about the Twisted-Python mailing list