Last active
April 15, 2018 15:12
-
-
Save whiledoing/aab6c90805d73695c9f0bd7c8e379be3 to your computer and use it in GitHub Desktop.
[python-repeated-timer] repeated timer impl with threading.Timer #python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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