I've seen a lot of Python scripts that use Threads in a class and a lot of them use the threading.Event()
. For example:
class TimerClass(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.event = threading.Event()
def run(self):
while not self.event.is_set():
print("something")
self.event.wait(120)
In the while
loop, why do they check the condition if they don't set self.event
?