code:
from threading import Timer, Event
from time import sleep
def hello(e):
print e
print 'Inside......'
while True:
if e.isSet():
print "hello_world"
break
if __name__ == '__main__':
e = Event()
t = Timer(1, hello(e,))
t.start()
print e.isSet()
sleep(2)
e.set()
print e.isSet()
Output:
[root@localhost ~]# python test_event.py
<threading._Event object at 0x7f440cbbc310>
Inside......
In the above code, I am trying to understand the Timer and, Event objects from python. If I run the above code, the Timer invokes the function hello() and it runs indefinitely. The main thread is not executing the line next to t.start(). What am I missing here??
Thanks.