Running a python program during idle time only

Donn Cave donn at drizzle.com
Sat May 21 01:23:03 EDT 2005


Quoth Mike Meyer <mwm at mired.org>:
| "los" <carlos80 at gmail.com> writes:
| > I'm trying to create a program similar to that of Google's desktop that
| > will crawl through the hard drive and index files.  I have written the
| > program and as of now I just put the thread to sleep for 1 second after
| > indexing a couple of files.
| >
| > I'm wondering if anyone knows of a way that I could make so that the
| > program will run at full speed only runs after the computer has been
| > idle for a while.  I've looked at the "nice" command but that's not
| > exactly what I want.
|
| On Unix, nice is exactly the answer. It's a lot more fine-grained than
| what you're talking about, though. But it's the way things like
| setiathome manage to run continuously without interfering with normal
| usage.

Well, he could certainly try it if he hasn't already, but I wouldn't
be too surprised if it really isn't exactly what he wants.  Maybe it
depends on the scheduler, and maybe things have gotten a lot better
in that department, but from my experience a process can be niced pretty
hard and still tie up a lot of resources.  A disk crawler sounds like
a good example.

I don't have any brilliant ideas, though.  Your suggestion to use
os.getloadavg sounds good to me.  It might be kind of neat if there
were some kind of APM ioctl that would register the calling process
for notification of pending disk spin down, low power mode etc.

	Donn



More information about the Python-list mailing list