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


Groups > comp.lang.python > #30132

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!post.news.xs4all.nl!not-for-mail
Return-Path <dihedral88888@googlemail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.028
X-Spam-Evidence '*H*': 0.94; '*S*': 0.00; 'subject:Python': 0.05; 'subject:How': 0.09; 'python': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.10; '(ubuntu': 0.16; 'escribi\xc3\xb3:': 0.16; 'subject:limit': 0.16; 'subject:usage': 0.16; 'processor': 0.17; 'typical': 0.17; 'solution.': 0.18; 'module': 0.19; 'all,': 0.21; 'import': 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; 'replace': 0.27; 'sleep': 0.29; 'related': 0.30; 'received:google.com': 0.34; 'from:addr:googlemail.com': 0.35; 'received:209.85.220': 0.35; 'sometimes': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'but': 0.36; 'useful': 0.36; "i'll": 0.36; 'possible': 0.37; 'does': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'unit': 0.38; 'object': 0.38; 'some': 0.38; 'where': 0.40; 'skip:" 10': 0.40; 'think': 0.40; 'selling': 0.64; 'limit': 0.65; 'regards.': 0.66; 'buying': 0.69; 'business': 0.70; 'lose': 0.71; 'saw': 0.75; '8bit%:70': 0.91; 'received:209.85.220.184': 0.91; 'few.': 0.93
Newsgroups comp.lang.python
Date Tue, 25 Sep 2012 15:39:39 -0700 (PDT)
In-Reply-To <mailman.1345.1348586032.27098.python-list@python.org>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=123.192.32.215; posting-account=5JdMBQoAAABHnS4mjpqEzxnmWtgiiVNw
References <505B326C.1060503@cnic.edu.cu> <mailman.1345.1348586032.27098.python-list@python.org>
User-Agent G2/1.0
X-Google-Web-Client true
X-Google-IP 123.192.32.215
MIME-Version 1.0
Subject Re: How to limit CPU usage in Python
From 88888 Dihedral <dihedral88888@googlemail.com>
To comp.lang.python@googlegroups.com
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
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>
Message-ID <mailman.1382.1348612782.27098.python-list@python.org> (permalink)
Lines 75
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1348612782 news.xs4all.nl 6920 [2001:888:2000:d::a6]:55972
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:30132

Show key headers only | View raw


DPalao於 2012年9月25日星期二UTC+8下午11時13分54秒寫道:
> On Jueves septiembre 20 2012 11:12:44 Rolando Cañer Roblejo escribió:
> 
> > 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).
> 
> > 
> 
> > Best regards.
> 
> 
> 
> Hola,
> 
> Sometimes a stupid solution like the following does the trick:
> 
> 
> 
> > import time
> 
> > for t in tasks:
> 
> >     do_something(t)
> 
> >     time.sleep(some_seconds)
> 
> 
> 
> where "some_seconds" is a number related to the typical time-scale of the 
> 
> tasks you are doing.
> 
> 
> 
> Hope it helps,
> 
> 
> 
> Regards
> 
> 
> 
> 
> 
> -- 
> 
> Miller's Slogan:
> 
> 	Lose a few, lose a few.

I think I'll prefer to use a generator of my object in python
to replace the sleep from the unix world. The reason is that I am not paid 
from selling or buying  work-stations in some business unit directly and immediately.

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


Thread

Re: How to limit CPU usage in Python DPalao <dpalao.python@gmail.com> - 2012-09-25 17:07 +0200
  Re: How to limit CPU usage in Python 88888 Dihedral <dihedral88888@googlemail.com> - 2012-09-25 15:39 -0700
  Re: How to limit CPU usage in Python 88888 Dihedral <dihedral88888@googlemail.com> - 2012-09-25 15:39 -0700

csiph-web