Running a python program during idle time only

James Carroll mrmaple at gmail.com
Mon May 23 14:19:44 EDT 2005


I think you can keep your sleep commands in your program to keep it
from hogging the cpu even when you are running it as nice.

You know, even more important than cpu load (since your indexer is
accessing the hard drive, is hard drive access..)  You can monitor the
bytes  / second going to the hard drives using a WMI query similar to
the one that gives you LoadPercentage for a cpu.

If something Is trying to read and write to the hard drive, and your
indexer is going at the same time, hard drive head contention can slow
down both processess to a crawl.  (Say your program is in C:/apps  and
another program is simutaneously trying to read from C:/data... the
heads have to seek back and forth between the two spots on the hard
drive, and it's much faster to do all the C:/apps accesses and then
later do all the C:/data accesses.)

So I think my approach would be to have the indexer take about 10% of
cpu load while it is active, and as soon as another process is doing
enough reading / writing to the hard drive, stop and wait for about
five minutes... then continuing.

The screen saver idea is another good one.  I found this the other day...
  http://homepage.hispeed.ch/py430/python/win32screensaver-0.3.2.zip

The problem is that any potential user that really likes their pretty
screen saver (Helios under Ubuntu... droool............ slurp.)  then
they can't have both your indexer and their pretty screensaver active
during idle time.

-Jim


On 23 May 2005 10:32:18 -0700, los <carlos80 at gmail.com> wrote:
> Thanks for all the replies.
>
> I did try using nice under windows.  I created a java program that
> would just loop and print numbers on the screen.  Even when I ran that
> simple program with nice, (lets call it program A) as soon as I started
> the program the cpu went all the way to 100% usage.  Then when I ran

<snip>



More information about the Python-list mailing list