Skip to content

Instantly share code, notes, and snippets.

@whiledoing
Last active April 15, 2018 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whiledoing/aab6c90805d73695c9f0bd7c8e379be3 to your computer and use it in GitHub Desktop.
Save whiledoing/aab6c90805d73695c9f0bd7c8e379be3 to your computer and use it in GitHub Desktop.
[python-repeated-timer] repeated timer impl with threading.Timer #python
from threading import _Timer
class RepeatedTimer(_Timer):
"""
See: https://hg.python.org/cpython/file/2.7/Lib/threading.py#l1079
"""
def run(self):
while not self.finished.is_set():
self.finished.wait(self.interval)
self.function(*self.args, **self.kwargs)
self.finished.set()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment