Question

Title says it all, is it possible to make python sleep for less than a second? WORKS:

import time
print ("foo")
time.sleep(0.2) #talking about the value of the time
print ("bar")

If not, then is there any other way? Thanks Using python 3.2.2 EDIT: Thanks guys, I'm pretty sure I have tried the above code before and it didn't work. Oh well... sorry for your waste if time. It worked now and I upgraded to 3.3

Was it helpful?

Solution

Based on the time.sleep() documentation:

The actual suspension time may be less than that requested because any caught signal will terminate the sleep() following execution of that signal’s catching routine. Also, the suspension time may be longer than requested by an arbitrary amount because of the scheduling of other activity in the system.

So it works but there are no guarantees.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top