I have a simple python class called Timer_ that takes an interval in seconds and runs the timer in the background. When it is done, it runs a finished function that returns true. How would I get the value of this function when the timer stops in the form of a variable? Thank you!
import threading
class Timer_():
def __init__(self, interval):
#interval in seconds
self.interval = interval
self.finished = False
def run(self):
self.timel = threading.Timer(float(self.interval), self.finish)
self.timel.start()
def finish(self):
self.finished = True
return True
def cancel(self):
self.timel.cancel()
time = Timer_(5)
time.run()
print(time.finished)