Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; 'subject:How': 0.09; 'python': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'terry': 0.09; '(ubuntu': 0.16; 'presume': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'subject:limit': 0.16; 'subject:usage': 0.16; 'wrote:': 0.17; 'processor': 0.17; 'jan': 0.18; 'solution.': 0.18; 'module': 0.19; 'all,': 0.21; 'meant': 0.21; 'tools,': 0.23; 'external': 0.24; 'linux': 0.24; 'script': 0.24; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; 'am,': 0.27; 'header:X -Complaints-To:1': 0.28; 'to:addr:python-list': 0.33; '(with': 0.33; 'done': 0.34; 'pm,': 0.35; 'there': 0.35; 'received:org': 0.36; 'but': 0.36; 'useful': 0.36; 'possible': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'end': 0.40; 'think': 0.40; 'easy': 0.60; 'first': 0.61; 'limited.': 0.64; 'limit': 0.65; 'saw': 0.75; 'received:fios.verizon.net': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: How to limit CPU usage in Python Date: Thu, 20 Sep 2012 12:53:41 -0400 References: <505B326C.1060503@cnic.edu.cu> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Gmane-NNTP-Posting-Host: pool-173-75-251-66.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20120824 Thunderbird/15.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1348160038 news.xs4all.nl 6879 [2001:888:2000:d::a6]:34725 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:29560 On 9/20/2012 12:46 PM, Terry Reedy wrote: > On 9/20/2012 11:12 AM, Rolando Ca=C3=B1er 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 usefu= l >> 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= =2E >> 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=20 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=20 piped-back output. --=20 Terry Jan Reedy