yielding control

Padraig Brady Padraig at Linux.ie
Tue Oct 15 18:47:28 CEST 2002

Rob Hall wrote:
> I have a long-running CPU intensive task under W98 and Python 2.2.  The
> trouble is, it hogs the CPU when I am trying to do other things.  Even the
> mouse is sluggish.
> Is there a way for me to yield control to the OS occasionally in my main
> loop?

Get a better operating system. The OS should share things
out so that at least you can control the mouse. On linux
you can say this process doesn't get more than X% of the CPU,
or trivially change the priorities of the python process
so that it's queued behind everything else.

If you are guaranteed that you can break your work into
scheduler sized units (10ms on windos 98) you could
do this yourself I suppose with sleep functions in the
loop, but seriously this is the operating systems job.


More information about the Python-list mailing list