cpu usage limit

rbt rbt at athop1.ath.vt.edu
Fri May 27 11:07:56 EDT 2005


mf wrote:
> Hi.
> 
> My problem:
> How can I make sure that a Python process does not use more that 30% of
> the CPU at any time. I only want that the process never uses more, but
> I don't want the process being killed when it reaches the limit (like
> it can be done with resource module).
> 
> Can you help me?
> 
> Thanks in advance.
> 
> Best regards,
> Markus
> 

Are you looping during a cpu intensive task? If so, make it sleep a bit 
like this:

for x in cpu_task:
     time.sleep(0.5)
     do(x)



More information about the Python-list mailing list