Low Orbit Flux Logo 2 F

Python How To Wait / Sleep

If you are working with anything that requires timing or waiting in Python you might end up needing to use the sleep function. This commonly comes in use when working with things that are network or internet related like web scraping. Really anything related to IO is likely to need the ability to sleep. This is also useful when working with threads and multithreaded programs.

To sleep or wait in Python just use the following:


import time
time.sleep(5) 

The above example specifies that it should sleep for 5 seconds. The amount of time to sleep is specified in seconds.

To sleep for 10 minutes you would use something like this:


time.sleep(600)