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


Groups > comp.lang.python > #29777

Re: How to limit CPU usage in Python

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <dwightdhutto@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.011
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'subject:Python': 0.05; 'level,': 0.07; 'subject:How': 0.09; 'python': 0.09; 'app,': 0.09; 'received:mail-vb0-f46.google.com': 0.09; 'portion': 0.13; 'asm': 0.16; 'subject:limit': 0.16; 'subject:usage': 0.16; 'variable.': 0.16; 'processor': 0.17; 'received:209.85.212.46': 0.18; 'module': 0.19; 'constant': 0.22; 'script': 0.24; 'header:In-Reply-To:1': 0.25; 'message-id:@mail.gmail.com': 0.27; 'received:209.85.212': 0.28; 'cpu': 0.29; 'sleep': 0.29; "i'm": 0.29; 'running': 0.32; 'could': 0.32; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'received:209.85': 0.35; 'there': 0.35; 'but': 0.36; 'compare': 0.36; 'useful': 0.36; 'possible': 0.37; 'being': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'your': 0.60; 'time,': 0.62; 'limit': 0.65; 'want,': 0.65; 'maybe,': 0.84; 'surface': 0.84; 'processes,': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=5kVHdA8bDbsTXy1Y8OaotaP/IL1ijxDq5M5kdoL1cRw=; b=XseIlscXRMSJ/Aqw/sfBiO2AaB4HsdyEu9CwMtFMAsd6tvd/xzM+OEzsIcZqDDKyQN PTIUIkFsZRKLhW/WAzKDMfj9UgE9h3MUT67Bd0GwW1m9KVW3JyJAp4TmLY01od91Qnkr vCKVaQHm+xRQDoCrpPGGa6rXHXPM2fzUhvoZ2FoWmte9yoYMG/Dr44eSKI0+rmiDHD2n blZyRndNe+cETFV56MPMdJopxLMq+PqCyupJZwJREApqjqqz9YD4kdj+iKKTxZZpoC0L Z6dQpSJstiLmkP+gsRS4lFSYLe4Rk8vgHtzy3i46dw1i4IYS8VcaFnxGLLWlmG9T5gp4 zNLQ==
MIME-Version 1.0
In-Reply-To <7xpq5d7j5e.fsf@ruckus.brouhaha.com>
References <mailman.960.1348154419.27098.python-list@python.org> <7xpq5d7j5e.fsf@ruckus.brouhaha.com>
Date Sat, 22 Sep 2012 23:04:39 -0400
Subject Re: How to limit CPU usage in Python
From Dwight Hutto <dwightdhutto@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
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.1095.1348369482.27098.python-list@python.org> (permalink)
Lines 27
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1348369482 news.xs4all.nl 6886 [2001:888:2000:d::a6]:36118
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:29777

Show key headers only | View raw


rites:
>> 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?
>
> One way is check your cpu usage once in a while, compare with elapsed
> time, and if your % usage is above what you want, sleep for a suitable
> interval before proceeding.
>

The script in constant runtime, unless it's in relation to other
processes, could be put on a % based sleep constant variable.

If the script is constantly running the same processes, and the OP
wants to limit it statistically, then at a critical portion in the
script sleep for a constant, or maybe, dynamic variable.

The only other is to create an app, disassemble it, and then refine
the asm instructions being used at the assembly level, but I'm just
scratching the surface of those enhancements.



-- 
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com

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


Thread

How to limit CPU usage in Python Rolando Cañer Roblejo <rolando.caner@cnic.edu.cu> - 2012-09-20 11:12 -0400
  Re: How to limit CPU usage in Python Tim Roberts <timr@probo.com> - 2012-09-22 13:55 -0700
    Re: How to limit CPU usage in Python Dwight Hutto <dwightdhutto@gmail.com> - 2012-09-22 23:24 -0400
  Re: How to limit CPU usage in Python Paul Rubin <no.email@nospam.invalid> - 2012-09-22 16:05 -0700
    Re: How to limit CPU usage in Python Dwight Hutto <dwightdhutto@gmail.com> - 2012-09-22 23:04 -0400
    Re: How to limit CPU usage in Python Tim Roberts <timr@probo.com> - 2012-09-24 21:09 -0700
    RE: How to limit CPU usage in Python "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-09-27 16:58 +0000
    Re: How to limit CPU usage in Python Jerry Hill <malaclypse2@gmail.com> - 2012-09-27 13:07 -0400

csiph-web