Skip to content

Instantly share code, notes, and snippets.

@js2854
Created September 29, 2018 05:30
Show Gist options
  • Save js2854/21253f8651320ed8c7908c9fc358139f to your computer and use it in GitHub Desktop.
Save js2854/21253f8651320ed8c7908c9fc358139f to your computer and use it in GitHub Desktop.
class RepeatingTimer(_Timer):
def __init__(self, init_delay, interval, function, args=[], kwargs={}):
_Timer.__init__(self, interval, function, *args, **kwargs)
self.init_delay = init_delay
def run(self):
self.finished.wait(self.init_delay)
self.function(*self.args, **self.kwargs)
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