Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #29560

Re: How to limit CPU usage in Python

From Terry Reedy <tjreedy@udel.edu>
Subject Re: How to limit CPU usage in Python
Date 2012-09-20 12:53 -0400
References <505B326C.1060503@cnic.edu.cu> <k3fh9e$be4$1@ger.gmane.org>
Newsgroups comp.lang.python
Message-ID <mailman.965.1348160038.27098.python-list@python.org> (permalink)

Show all headers | View raw


On 9/20/2012 12:46 PM, Terry Reedy wrote:
> On 9/20/2012 11:12 AM, Rolando CaƱer Roblejo wrote:
>> Hi all,
>>
>> Is it possible for me to put a limit in the amount of processor usage (%
>> CPU) that my current python script is using? Is there any module useful
>> for this task? I saw Resource module but I think it is not the module I
>> am looking for. Some people recommend to use nice and cpulimit unix
>> tools, but those are external to python and I prefer a python solution.
>> I am working with Linux (Ubuntu 10.04).
>
> Call the external tools with subprocess.open.

I meant to end that with ? as I don't know how easy it is to get the 
external id of the calling process that is to be limited. I presume that 
can be done by first calling ps (with subprocess) and searching the 
piped-back output.


-- 
Terry Jan Reedy

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: How to limit CPU usage in Python Terry Reedy <tjreedy@udel.edu> - 2012-09-20 12:53 -0400

csiph-web