[Twisted-Python] twisted.internet.task.LoopingCall
Hi all, I'm using the twisted.internet.task.LoopingCall system to run periodic tasks in a Twisted server. If I had code like this: from twisted.internet.task import LoopingCall lp = LoopingCall(someFunction) lp.start(5.0) # run every 5 seconds Is there anything in LoopingCall to keep it from trying to run someFunction() if the previous call is still running? For instance a call to someFunction() takes longer than 5 seconds, will LoopingCall hold off or will it call someFuction() anyway causing two 'instances' to run? Thanks, Doug
On 6/4/09 4:12 PM, Doug Farrell wrote:
Hi all,
I'm using the twisted.internet.task.LoopingCall system to run periodic tasks in a Twisted server. If I had code like this:
from twisted.internet.task import LoopingCall
lp = LoopingCall(someFunction) lp.start(5.0) # run every 5 seconds
Is there anything in LoopingCall to keep it from trying to run someFunction() if the previous call is still running? For instance a call to someFunction() takes longer than 5 seconds, will LoopingCall hold off or will it call someFuction() anyway causing two 'instances' to run?
Thanks, Doug
per http://twistedmatrix.com/documents/current/api/twisted.internet.task.Looping... If someFunction returns a Deferred, it will not be rescheduled if the Deferred has not fired. e.g. def someFunction(): d = someDeferredReturningOperation() d.addCallbacks(success, error) return d lp = LoopingCall(someFunction) lp.start(5.0) # run every 5 seconds Lucas
participants (2)
-
Doug Farrell -
Lucas Taylor