469,306 Members | 1,987 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,306 developers. It's quick & easy.

Pausing python programs

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
gs****@oxfam.org.uk

Jul 18 '05 #1
3 2303
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
gs****@oxfam.org.uk

Sleep() (at least on windoze) will suspend your app from execution. From
some experiments I think Python's time.sleep() uses it.
max
Jul 18 '05 #2
Thanks Max. Big help.
regards
Jul 18 '05 #3
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

gs****@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 <mf********@gatwick.westerngeco.slb.com>
Jul 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

38 posts views Thread by kbass | last post: by
145 posts views Thread by David MacQuigg | last post: by
114 posts views Thread by Maurice LING | last post: by
68 posts views Thread by Lad | last post: by
14 posts views Thread by Mark Dufour | last post: by
7 posts views Thread by Charles Law | last post: by
reply views Thread by Fuzzyman | last post: by
2 posts views Thread by redefined.horizons | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.