How to run a repeating timer every n minutes?
VYAS ASHISH M-NTB837
ashish.vyas at motorola.com
Thu Oct 29 14:03:13 CET 2009
Thanks a lot, this helps.
From: python-list-bounces+ntb837=motorola.com at python.org
[mailto:python-list-bounces+ntb837=motorola.com at python.org] On Behalf Of
Sent: Thursday, October 29, 2009 5:19 PM
To: python-list at python.org
Subject: Re: How to run a repeating timer every n minutes?
Ashish Vyas wrote:
> Dear All
> How do I write a code that gets executed 'every x' minutes?
> Ashish Vyas
Here is one way -
self.event = threading.Event()
while not self.event.is_set():
""" The things I want to do go here. """
In your main program -
- to start the timer
tmr = Timer()
- to stop the timer
It is easy to extend this by passing the number_of_seconds_to_wait, or a
function name to be executed, as arguments to the Timer.
More information about the Python-list