Time delay loop - better way?
Peter Otten
__peter__ at web.de
Thu Jul 1 03:52:39 EDT 2004
Dan Bishop wrote:
> "Terry Reedy" <tjreedy at udel.edu> wrote in message
> news:<mailman.316.1088637472.27577.python-list at python.org>...
>> "Conrad" <bogus_address at nospam.com> wrote in message
>> news:pan.2004.06.30.22.48.43.405408 at nospam.com...
>> > Greetings,
>> >
>> > Q: Is there some way to gracefully suspend a python app for a second or
>> > so then resume?
>>
>> time.sleep(secs)
>>
>> >I could write the classic basic dumb
>> > loop-tenzillion-times delay, but that seems inelegant, and well,
>> > just wrong.
>>
>> I believe such loops either hog the CPU or take longer than intended.
>
> Or even worse, a faster CPU comes out and the loop is *shorter* than
> intended.
Well, you could adjust the delay to CPU speed. But avoid 16-bit counters if
you expect your program to run on fast machines with more than 20 MHz :-)
http://www.merlyn.demon.co.uk/pas-r200.htm#R200
Peter
More information about the Python-list
mailing list