Pausing python programs

Martin Franklin mfranklin1 at gatwick.westerngeco.slb.com
Thu Jan 29 10:56:10 EST 2004


On Thu, 2004-01-29 at 09:41, Graham wrote:
> How can I cause a python program to pause/suspend execution for a period of
> time?  I am checking status of an external system and only want to check
> every second as opposed to my current which checks may times a secnod and
> hogs my cpu in the process!!!
> 
> Thank you to anyone who can help.
> 
> Graham Smith
> 
> PeopleSoft Technical Team Leader
> OXFAM GB
> +44 (1865) 313255
gsmith at oxfam.org.uk


You should really get into pydoc:-)  For example

pydoc time

Help on module time:
                                                                                
NAME
    time - This module provides various functions to manipulate time
values.
                                                                                
FILE
    /usr/local/lib/python2.3/lib-dynload/time.so


<snip>


    Functions:
                                                                                
    time() -- return current time in seconds since the Epoch as a float
    clock() -- return CPU time since process start as a float
    sleep() -- delay for a number of seconds given as a float
    gmtime() -- convert seconds since Epoch to UTC tuple
    localtime() -- convert seconds since Epoch to local time tuple
    asctime() -- convert time tuple to string
    ctime() -- convert time in seconds to string
    mktime() -- convert local time tuple to seconds since Epoch
    strftime() -- convert time tuple to string according to format
specification    strptime() -- parse string to time tuple according to
format specification
    tzset() -- change the local timezone
 


so time.sleep(1) could be what you are after.  

Also don't forget google is you friend :-)

Cheers
Martin


-- 
Martin Franklin <mfranklin1 at gatwick.westerngeco.slb.com>





More information about the Python-list mailing list