[Twisted-web] Reactor events help request ..

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Wed Feb 24 09:33:33 EST 2010


On 01:12 am, david.watson at windriver.com wrote:
>
>Hi Folks ..
>
>I'm not entirely a newbie a python and twisted, but I have come to the
>point where I need a bit more expertise on this topic, so I am hoping
>that I have come to the right place ..
>
>What  I'm hoping, that  you folks can help out with a minor problem 
>that
>I am having with the twistd reactor class and/or the callLater function
>
>I have been using a reactor.callLater function to schedule an event 
>that
>happens in the reactor to send out a heartbeat type message at regular
>intervals .. This works great !
>
>However, it appears to me that the self.sendLine(msg)  and or the
>self.transport.write(msg) writing  functions are blocked functions
>waiting for a reactor event to occur at a future scheduled time before
>acutally flushing out the internal write buffers ..

This isn't the intended behavior.  The most common mistake which leads 
to it is trying to use Twisted APIs such as these from a different 
thread than the one where reactor.run() was called.  The only thread- 
safe Twisted API is reactor.callFromThread.

You didn't say anything about threads in your post, so I don't know if 
this is the problem you're having, but since it's so common I thought 
I'd mention it.

Jean-Paul



More information about the Twisted-web mailing list