sleep function

Doug Stanfield DOUGS at oceanic.com
Tue Aug 29 22:16:54 EDT 2000


>From the Python Library Reference at http://www.python.org/doc , looking in
the index, under 's', I find "sleep() (in time) ":

file:///C:/Program%20Files/Python/Doc/lib/module-time.html#l2h-1023

So if you do:

import time

time.sleep(1) # wait one second
time.sleep(.5) # wait half a second
time.sleep(900) # wait fifteen minutes

As for executing something every so many minutes, a few ideas:

# simplisticly if the function my_function() takes a very short time:
while 1:
    my_function()
    time.sleep(900)

# if you want to be somewhat more precise:
while 1:
    first = time.time()
    my_function()
    time.sleep(900-(time.time()-first))

Hope this helps.

-Doug-

> -----Original Message-----
> From: Arnaldo Riquelme [mailto:javanet at dynacap.com]
> Sent: Tuesday, August 29, 2000 3:34 PM
> To: python-list at python.org
> Subject: sleep function
> 
> 
> Newbie question:
> 
> 
> Does python has a function similar to  sleep() in perl?
> If so what is it? How do I make a function to execute every (5,15,10)
> minutes ?
> 
> Thanks
> 
> 
> -- 
> http://www.python.org/mailman/listinfo/python-list
> 




More information about the Python-list mailing list