Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make Python Program Wait

Tags:

python

I need to make my python program wait for 200ms before polling for an input of some description. In C# for example, I could use Thread.Sleep() to achieve this. What is the simplest means of doing this in python?

like image 740
richzilla Avatar asked Mar 18 '13 08:03

richzilla


2 Answers

Use Time module.

For example, to delay 1 second :

import time
time.sleep(1) # delay for 1 seconds

In your case, if you want to get 200 ms, use this instead:

time.sleep(0.2)

time.sleep also works with float.

like image 189
Thanakron Tandavas Avatar answered Oct 18 '22 14:10

Thanakron Tandavas


If you simply want to sleep you can try:

import time

time.sleep(0.2)
like image 29
cnicutar Avatar answered Oct 18 '22 14:10

cnicutar