Alexey Ustinnikov Alexey Ustinnikov - 1 year ago 83
Python Question

Is there a way to deny scheduled Timer event?

Consider this. I want to deny execution of Timer event:

import threading

def say_hello():
print 'hello'

threading.Timer(10, say_hello, ()).start()
# now for some reason my plans have changed
# is there a way to erase that Timer and deny execution of say_hello?

Answer Source
t = threading.Timer(10, say_hello, ())
t.start()  # start timer
t.cancel()  # stop it
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download