Timer runs only once.
siva gnanam
sivagnanam.student at gmail.com
Wed Nov 30 10:06:02 EST 2016
On Wednesday, November 30, 2016 at 8:11:49 PM UTC+5:30, vnthma... at gmail.com wrote:
> from threading import Timer
>
> class TestTimer:
> def foo(self):
> print("hello world")
> self.startTimer()
>
> def startTimer(self):
> self.t1 = Timer(5, self.foo)
> self.t1.start()
>
> timer = TestTimer()
> timer.startTimer()
I think in this example, We are creating Timer object every 5 seconds. So every time it will span a new Timer. I don't know what happened to the previous timers we created.
More information about the Python-list
mailing list