[Twisted-Python] Timers in Twisted

Glyph Lefkowitz glyph at twistedmatrix.com
Mon Jul 20 06:36:47 MDT 2009


On Mon, Jul 20, 2009 at 8:26 AM, David Guerin <david at strotos.com> wrote:

> Hey all,
>
> I'm pretty new to Twisted Framework but things are going along nicely.
> At the moment I am trying to get a timer to fire off say every 5
> minutes.
> What's the best way to do this with twisted?
> I found an old link to a how to with timers in twisted on the
> twistedmatrix.com site but there wasn't a web page there when I clicked
>

You can use LoopingCall: <
http://twistedmatrix.com/documents/8.2.0/api/twisted.internet.task.LoopingCall.html>,
like so:

from twisted.internet.task import LoopingCall
MINUTES = 60.0
def myTimer():
      doSomeStuff()
repeater = LoopingCall(myTimer)
repeater.start(5 * MINUTES)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20090720/cdfd58ce/attachment.html>


More information about the Twisted-Python mailing list