I am trying to implement a timer structure which runs a function periodically. To do that, I used threading.Timer object like below:
class AClass:
def function(self):
print('Begins ...')
# some operations here ...
print('Ends!')
def trigger(self):
self.market_listener_thread = threading.Timer(DATA_COLLECTOR_FREQUENCY, self.listen, [], {}).start()
class MainClass:
def anotherFunction:
aClass = AClass()
aClass.trigger()
Here my function runs once and prints Begins ...
and Ends!
. But it does not run for a second time and also does not produce an error, warning anything. What is wrong here?