A threading.Timer executes a function once. This function can "work forever" if you want, for example:
import time def hello(): while True: print "Hello, Word!" time.sleep(30.0)
Using multiple instances of Timer will require significant resources without real added value. If you want to be non-invasive for a function that you repeat every 30 seconds, an easy way:
import time def makerepeater(delay, fun, *a, **k): def wrapper(*a, **k): while True: fun(*a, **k) time.sleep(delay) return wrapper
and then schedule makerepeater(30, hello) instead of hello .
For more complex operations, I recommend the standard sched library module.
source share