control CPU usage

Sean DiZazzo half.italian at
Sat Sep 19 19:18:13 CEST 2009

On Sep 19, 9:17 am, kakarukeys <kakaruk... at> wrote:
> Hi,
> When I am running a loop for a long time, calculating heavily, the CPU
> usage
> is at 100%, making the comp not so responsive. Is there a way to
> control the
> CPU usage at say 80%? putting a time.sleep(0.x) doesn't seem to help
> although CPU usage level is reduced, but it's unstable.
> Regards,
> W.J.F.

If you are on linux, you can use the 'nice' command.  It will still
take 100%, but will give it up to other processes that need to use the

nice -n 19 <script>

In windows, I guess you could change the priority of the process in
the Task Manager.  Not sure how to do it programatically.


More information about the Python-list mailing list