Message from discussion
How to limit CPU usage in Python
Received: by 10.180.107.167 with SMTP id hd7mr1328356wib.0.1348765679854;
Thu, 27 Sep 2012 10:07:59 -0700 (PDT)
Path: q11ni76961411wiw.1!nntp.google.com!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path: <malaclyp...@gmail.com>
X-Original-To: python-l...@python.org
Delivered-To: python-l...@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: <5B80DD153D7D744689F57F4FB69AF474166CA...@SCACMX008.exchad.jpmchase.net>
References: <mailman.960.1348154419.27098.python-l...@python.org>
<7xpq5d7j5e....@ruckus.brouhaha.com>
<5B80DD153D7D744689F57F4FB69AF474166CA...@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 <malaclyp...@gmail.com>
To: "Prasad, Ramit" <ramit.pra...@jpmorgan.com>
Cc: "python-l...@python.org" <python-l...@python.org>
X-BeenThere: python-l...@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-requ...@python.org?subject=unsubscribe>
List-Archive: <http://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-l...@python.org>
List-Help: <mailto:python-list-requ...@python.org?subject=help>
List-Subscribe: <http://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-requ...@python.org?subject=subscribe>
Newsgroups: comp.lang.python
Message-ID: <mailman.1499.1348765679.27098.python-l...@python.org>
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: ab...@xs4all.nl
Content-Type: text/plain; charset=UTF-8
On Thu, Sep 27, 2012 at 12:58 PM, Prasad, Ramit
<ramit.pra...@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