11
from threading import Timer

class test_timer():
    def __init__(self):
        self.awesum="hh"
        self.timer = Timer(1,self.say_hello,args=["WOW"])
    def say_hello(self,message):
        self.awesum=message
        print 'HIHIHIIHIH'
        print message
        raise Exception("hi")

if __name__ == '__main__':
    print 'Got to main'
    x=test_timer()

When I run the code above, my callback method is never triggered. I have been trying to solve this for hours but cannot figure it out >.<

To test, the timer. I run this code and check to see if x.awesum is 'WOW'

1 Answer 1

17

You never start the timer. You need to:

self.timer.start()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.