Timer runs only once.
siva gnanam
sivagnanam.student at gmail.com
Wed Nov 30 09:05:34 EST 2016
The following program print hello world only once instead it has to print the string for every 5 seconds.
from threading import Timer;
class TestTimer:
def __init__(self):
self.t1 = Timer(5.0, self.foo);
def startTimer(self):
self.t1.start();
def foo(self):
print("Hello, World!!!");
timer = TestTimer();
timer.startTimer();
(program - 1)
But the following program prints the string for every 5 seconds.
def foo():
print("World");
Timer(5.0, foo).start();
foo();
(program - 2)
Why (program - 1) not printing the string for every 5 seconds ? And how to make the (program - 1) to print the string for every 5 seconds continuously.
More information about the Python-list
mailing list