Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pausing a called function for a few seconds

Tags:

python

I have a function F1 that loops continuously (while loop). I have set a condition, if met, calls another function F2 inside function F1. Once called, the function F2 shouldn't be called again for a few seconds, say 3 secs, even if the condition is met again within 3 seconds. But function F1 has to be looping continuously. How do I achieve it?

like image 354
Gautham Avatar asked Jul 25 '26 07:07

Gautham


1 Answers

Save time when you call F2 (say time_f2). Next time the condition is met, compare now with time_f2 and call F2 only if the difference is more than 3 seconds.

like image 96
Psytho Avatar answered Jul 27 '26 22:07

Psytho