time.sleep() and cpu cycles

Timothy Grant tjg at exceptionalminds.com
Fri Feb 9 12:45:37 EST 2001


Hi,

We were having some problems on one of our Linux boxes with inodes being
allocated and not deallocated. (kernel 2.2.14).

So, wanting to understand this behaviour, I wrote a little python logging
script that reads the inode info out of /proc every 10 seconds, and then
uses python's logging facilities to write out a log file with what it found.
This solution worked wonderfully, and gave us all the information we needed
about what was going on on the box just before it would die.

We have resolved the problem, but left the logging programme running just
for fun.

When the box is under load with users logged running things, the python
process does not interfere with anything.

However, on an unloaded system, the python process is taking 60% of the CPU.
Maybe that's the way it should be, but it sure seemed odd to me. I use
time.sleep() for my delay loop, and was wondering if there is a better way
to put a task to sleep, or if what I'm seeing is normal behaviour.

-- 
Stand Fast,
    tjg.

Timothy Grant                         tjg at exceptionalminds.com
Red Hat Certified Engineer            www.exceptionalminds.com
Avalon Technology Group, Inc.                   (503) 246-3630
>>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<<
>>>>This machine was last rebooted:  23 days 21:51 hours ago<<




More information about the Python-list mailing list