I have an array of events and their polling time like this. [{"A":5,"B":7,"C":9}]
So event A (some function) needs to be called every x seconds, in the above example A function needs to be called every 5th second from now (not just once, but keep on repeating)
and B function needs to be called every 7th second from now and so on.
At 35th second Both A and B would be called(considering function A and B returns almost instantaneously assume printf() )
Is there a standard algorithm for this?if not any pointers on how to achieve this?
something on this line,(doesnt work though)
import threading
class A():
def A():
printf "A"
def B():
printf "B"
def __init__(self, *args, **kwargs):
self.iteration = 1
def execute(self,arr):
for key in arr[0]:
print key, arr[key]
t1 = threading.Timer(arr[key], key).start()
t2 = threading.Timer(arr[key], key).start()
A().execute([{"A":5,"B",7}])