473,385 Members | 1,329 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 2428
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

38
by: kbass | last post by:
In different articles that I have read, persons have constantly eluded to the productivity gains of Python. One person stated that Python's productivity gain was 5 to 10 times over Java in some in...
145
by: David MacQuigg | last post by:
Playing with Prothon today, I am fascinated by the idea of eliminating classes in Python. I'm trying to figure out what fundamental benefit there is to having classes. Is all this complexity...
114
by: Maurice LING | last post by:
This may be a dumb thing to ask, but besides the penalty for dynamic typing, is there any other real reasons that Python is slower than Java? maurice
68
by: Lad | last post by:
Is anyone capable of providing Python advantages over PHP if there are any? Cheers, L.
14
by: Mark Dufour | last post by:
After nine months of hard work, I am proud to introduce my baby to the world: an experimental Python-to-C++ compiler. It can convert many Python programs into optimized C++ code, without any user...
7
by: Charles Law | last post by:
My first thought was to call WorkerThread.Suspend but the help cautions against this (for good reason) because the caller has no control over where the thread actually stops, and it might have...
0
by: Fuzzyman | last post by:
It's finally happened, `Movable Python <http://www.voidspace.org.uk/python/movpy/>`_ is finally released. Versions for Python 2.3 & 2.4 are available from `The Movable Python Shop...
2
by: redefined.horizons | last post by:
I've written a few classes that I have been testing in IDLE. However, every time I make a change to the classes based on the testing I have to walk through all he steps of preparing the classes for...
0
by: Grayzag | last post by:
Hi there, As part of my Software course, i have to create a game. Since I originally started out with python, I was used to it being really easy to create a main loop to control the game with a...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.