I am trying to make simulation of telecommunication network in order to test some routing algorithm. Requests come according to Poisson distribution and their holding times follow exponential distribution.
After finding route for some request Timer should be activated to update values of residual link capacities after expiration of specific holding time interval. I know that I can use threading.Timer to call some function with delay, but before holding time expires many other request will arrive and I need to run separate Timer for each of them.
Not related with my algorithm, today I tried to run this code:
def hello(i):
print i
for i in range(0,10):
t = threading.Timer(2,hello,[i])
t.start()
I wanted to print numbers from range (0,10) in intervals of 2 seconds, but output is totally weird. After few seconds I got:
0
1
32
4
5
6
7
89
So, it seems that I cannot use Timer for this purpose. Do you have some idea how to solve this problem?
3and2on the same line). If you want to run this all in one thread and wait 2 seconds between each call, just usetime.sleep(2)in yourforloop and callhello().