Couple of newbie questions...
Peter Hansen
peter at engcorp.com
Thu Jul 26 21:51:00 EDT 2001
Scott Taylor wrote:
>
> 1) time.sleep doesn't seem to release time back to the Win32
> subsystem. I had a tight loop, and CPU was maxed out at 100% even if
> I did a PumpWaitingMessages w/ a time.sleep. To actually get the loop
> to return slices of time back to windows and not max out the CPU I had
> to do a PumpWaitingMessages followed by a win32api.Sleep(0) call. My
> question is - shouldn't time.sleep actually make the process sleep w/o
> hogging CPU?
It does on my system.
Try executing this in a DOS prompt and compare with your other situation:
python -c "import time; time.sleep(30)"
On my machine (Win98 release 1) System Monitor shows only its
usual 30% or so, same as when I am just sitting at a DOS prompt...
(Disclaimer: no, I don't believe System Monitor is an appropriate
tool for this purpose, but I also know time.sleep() does not
busy-wait under Windows in any case I've ever seen.)
--
----------------------
Peter Hansen, P.Eng.
peter at engcorp.com
More information about the Python-list
mailing list