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


Groups > comp.lang.python > #29699

Re: How to limit CPU usage in Python

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <cameron@cskk.homeip.net>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; 'subject:How': 0.09; 'python': 0.09; 'terry': 0.09; 'cc:addr :python-list': 0.10; '(ubuntu': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'limiting': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'presume': 0.16; 'received:202.125.174': 0.16; 'received:202.125.174.133': 0.16; 'received:boardofstudies.nsw.edu.au': 0.16; 'received:cskk.homeip.net': 0.16; 'received:edu.au': 0.16; 'received:harvey.boardofstudies.nsw.edu.au': 0.16; 'received:homeip.net': 0.16; 'received:nsw.edu.au': 0.16; 'reedy': 0.16; 'simpson': 0.16; 'subject:limit': 0.16; 'subject:usage': 0.16; 'wrote:': 0.17; 'processor': 0.17; 'solution.': 0.18; 'module': 0.19; 'meant': 0.21; 'cc:2**0': 0.23; 'tools,': 0.23; 'cc:no real name:2**0': 0.24; 'external': 0.24; 'linux': 0.24; 'script': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; 'am,': 0.27; '(with': 0.33; 'done': 0.34; 'pm,': 0.35; 'there': 0.35; 'but': 0.36; 'received:au': 0.36; 'useful': 0.36; 'possible': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'end': 0.40; 'think': 0.40; 'easy': 0.60; 'content-disposition:inline': 0.60; 'first': 0.61; 'limited.': 0.64; 'limit': 0.65; 'saw': 0.75; 'yourself,': 0.75
Date Sat, 22 Sep 2012 09:44:04 +1000
From Cameron Simpson <cs@zip.com.au>
To Terry Reedy <tjreedy@udel.edu>
Subject Re: How to limit CPU usage in Python
MIME-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Disposition inline
Content-Transfer-Encoding 8bit
In-Reply-To <k3fhmq$be4$2@ger.gmane.org>
User-Agent Mutt/1.5.21 (2010-09-15)
References <k3fhmq$be4$2@ger.gmane.org>
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1050.1348271054.27098.python-list@python.org> (permalink)
Lines 20
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1348271054 news.xs4all.nl 6985 [2001:888:2000:d::a6]:37714
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:29699

Show key headers only | View raw


On 20Sep2012 12:53, Terry Reedy <tjreedy@udel.edu> wrote:
| On 9/20/2012 12:46 PM, Terry Reedy wrote:
| > On 9/20/2012 11:12 AM, Rolando CaƱer Roblejo wrote:
| >> 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.

If you're limiting yourself, os.getpid().
-- 
Cameron Simpson <cs@zip.com.au>

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


Thread

Re: How to limit CPU usage in Python Cameron Simpson <cs@zip.com.au> - 2012-09-22 09:44 +1000
  Re: How to limit CPU usage in Python Ramchandra Apte <maniandram01@gmail.com> - 2012-09-21 20:05 -0700
  Re: How to limit CPU usage in Python Ramchandra Apte <maniandram01@gmail.com> - 2012-09-21 20:05 -0700

csiph-web