jeudi 23 avril 2015

No delay in function call

For a random delayed execution of a function i used following code in a for loop with index i decreasing for each iteration and randomtime is an array of random values:

threading.Timer(int(random.random()*10)+i, postit(data)).start()

but on examining the log I see that postit function is not delayed at all and it just executes all of them when called.

So how to really randomly delay each function call without using timer.sleep as it freezes the app.




Aucun commentaire:

Enregistrer un commentaire