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


Groups > comp.lang.python > #30309

Re: How to limit CPU usage in Python

Path csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.85.MISMATCH!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <malaclypse2@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; 'subject:How': 0.09; 'received:mail-vc0-f174.google.com': 0.09; 'sep': 0.09; 'url:activestate': 0.09; 'windows,': 0.09; 'cc:addr :python-list': 0.10; 'assume': 0.11; 'jerry': 0.16; 'recipe': 0.16; 'subject:limit': 0.16; 'subject:usage': 0.16; 'wrote:': 0.17; 'thu,': 0.17; 'handles': 0.18; 'module': 0.19; 'appropriate': 0.20; 'context.': 0.22; 'cc:2**0': 0.23; 'to:2**1': 0.23; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'message-id:@mail.gmail.com': 0.27; 'cpu': 0.29; 'priority': 0.29; 'received:209.85.220.174': 0.29; 'url:code': 0.29; 'handle': 0.33; 'received:google.com': 0.34; 'process,': 0.35; 'pm,': 0.35; 'received:209.85.220': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'level.': 0.36; 'should': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'sure': 0.38; 'little': 0.39; 'header:Received:5': 0.40; 'think': 0.40; 'different': 0.63; 'believe': 0.69; 'manages': 0.84
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 :cc:content-type; bh=B9PgrGUXxJ4qtWlBsGndZoKsmgqJDEd+SRa//S8OUa8=; b=H6TH26CR+uOUqEWjm0ToGPrs0Z5P9hRx2La3rOfA3gk7PcA1WAqJrw3FI0FEhLg4LI 7fUZORehjYNEZ609tkh25Eo5QdteLjgjf6dwoO16grZky2j/CqgKDo56ut+J5MWqmGsj lBCNM4ZHl8qxoiClCWDvWGJikIdWu88/RAEeJKD/28kXiQZd75LOBwdnB15iNT9EkjUH 0JMTjVvxGNMjRwKq/lXfntaMwShkrE6HymtgTb5kNGop6ATfSZO5kwejtJiSSnpyIa7e inzeNMql5h+zRsldk9mDLi0HoPwKVvx3b5c6RGSZ5Kip69LLoP5ThJuQXbXuB9z0vk1m tfIA==
MIME-Version 1.0
In-Reply-To <5B80DD153D7D744689F57F4FB69AF474166CAA91@SCACMX008.exchad.jpmchase.net>
References <mailman.960.1348154419.27098.python-list@python.org> <7xpq5d7j5e.fsf@ruckus.brouhaha.com> <5B80DD153D7D744689F57F4FB69AF474166CAA91@SCACMX008.exchad.jpmchase.net>
Date Thu, 27 Sep 2012 13:07:56 -0400
Subject Re: How to limit CPU usage in Python
From Jerry Hill <malaclypse2@gmail.com>
To "Prasad, Ramit" <ramit.prasad@jpmorgan.com>
Content-Type text/plain; charset=UTF-8
Cc "python-list@python.org" <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.1499.1348765679.27098.python-list@python.org> (permalink)
Lines 14
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1348765679 news.xs4all.nl 6884 [2001:888:2000:d::a6]:39254
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:30309

Show key headers only | View raw


On Thu, Sep 27, 2012 at 12:58 PM, Prasad, Ramit
<ramit.prasad@jpmorgan.com> wrote:
> On *nix you should just set the appropriate nice-ness and then
> let the OS handle CPU scheduling. Not sure what you would do
> for Windows--I assume OS X is the same as *nix for this context.

On windows, you can also set the priority of a process, though it's a
little different from the *nix niceness level.  See
http://code.activestate.com/recipes/496767/ for a recipe using
pywin32.  I believe the psutil module handles this too, but I don't
think it manages to abstract away the platform differences.

-- 
Jerry

Back to comp.lang.python | Previous | NextPrevious 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