-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Description
class Monitor(Thread):
"""Thread that calls a monitoring function every ``delay`` seconds."""
def __init__(self, delay, func):
super().__init__(daemon=True)
self.stopped = False
self.delay = delay
self.func = func
self.start_time = time.time()
self.count = 0
def run(self):
while not self.stopped:
time.sleep(0)
self.func()
self.count += 1
def stop(self):
self.stopped = True
# (time.time() - self.start_time) / self.count = 2sec when self.delay == 0.1
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels