Python Threading con objeto de evento
He visto muchos scripts de Python que usan Threads en una clase y muchos de ellos usan elthreading.Event()
. Por ejemplo:
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)
En elwhile
bucle, ¿por qué comprueban la condición si no se establecenself.event
?