Pause loop iteration

I am working on integration with an API that has a limit on the number of requests per second. Is there a way when starting a loop forin python to delay each loop? Conceptually, something like -

def function(request):
    for x in [a,b,c,d,...]:
        do something
        wait y seconds

Thank.

+5
source share
1 answer
import time
...
time.sleep(5)

It will sleep for 5 seconds. See http://docs.python.org/library/time.html#time.sleep

+8
source

All Articles