[Twisted-Python] LoopingCall question : ping w/ timeout using shared variable -> problem

Gabriel Rossetti gabriel.rossetti at arimaz.com
Thu Sep 25 08:40:01 EDT 2008


Gabriel Rossetti wrote:
> Hello everyone!
>
> I have written some code uses a LoopingCall to send a "ping" at 
> regular intervals. If it hasn't received an answer before the next 
> call, it notifies me that the destination isn't available, if it does 
> then it does nothing. I am getting lots of "unavailables" on hosts 
> that are, I tried augmenting the timeout (the ping interval) and it 
> doesn't change anything. I think what is happening is I'm using a 
> simple variable to keep the availability state and that since protocol 
> and the LoopingCall's callback both access the variable, this causes 
> problems. Is there a better way of doing things or am I bound to use 
> some sort of locking mechanism? If I have to use locking, which one do 
> you recommend?
>
> Thank you,
> Gabriel
>
I tried using a reactor.callLater call and if it fires then it notifies 
me (unavailable) and if I get the response I cancel it and start over, 
this seams like a better approach.

Gabriel




More information about the Twisted-Python mailing list