I want to run a function every 5 seconds. This code would work:
import threading
def notify():
threading.Timer(5.0, notify).start()
notify()
What if the function need parameter from the previous run ? I tried this:
import threading
def notify(since):
threading.Timer(5.0, notify(since)).start()
# initial_id is just an integer, eg 423455677
notify(initial_id)
I get error:
Traceback (most recent call last):
File "/Users/paulyu/anaconda/lib/python3.4/threading.py", line 911, in _bootstrap_inner
self.run()
File "/Users/paulyu/anaconda/lib/python3.4/threading.py", line 1177, in run
self.function(*self.args, **self.kwargs)
TypeError: notify() missing 1 required positional argument: 'since'
Howe to fix it ? Your advice is much appreciated. Thanks Paul