Answer the question
In order to leave comments, you need to log in
How to pause the loop every 20 seconds for 2 seconds?
There is a cycle. You need to stop it every 20 seconds for 2 seconds. How can this be implemented?
Answer the question
In order to leave comments, you need to log in
import time
repeat_interval = 5
waiting_interval = 2
destination = time.time() + repeat_interval
for x in xrange(100000000):
# Your code here
time.sleep(0.001)
now = time.time()
if now > destination:
destination += repeat_interval
print('Go sleeping')
time.sleep(waiting_interval)
print('Waking up')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question