Pausing python programs

G

Graham

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
(e-mail address removed)
 
M

max khesin

Graham said:
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
(e-mail address removed)
Sleep() (at least on windoze) will suspend your app from execution. From
some experiments I think Python's time.sleep() uses it.
max
 
M

Martin Franklin

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
(e-mail address removed)


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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,111
Latest member
VetaMcRae
Top