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


Groups > comp.lang.python > #6095

Re: Multiprocessing: don't push the pedal to the metal?

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <awilliam@whitemice.org>
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; 'exception,': 0.07; 'unix/linux': 0.07; 'python': 0.08; 'url:pypi': 0.08; 'etc...': 0.09; 'exceeds': 0.09; 'figuring': 0.09; 'indicates': 0.09; 'specific.': 0.09; 'subject:don': 0.09; 'values,': 0.09; 'linux': 0.11; 'am,': 0.14; 'wrote:': 0.14; 'library': 0.15; 'adam': 0.16; 'adjustment': 0.16; 'docs,': 0.16; 'from:addr:awilliam': 0.16; 'from:addr:whitemice.org': 0.16; 'from:name:adam tauno williams': 0.16; 'library"': 0.16; 'message-id:@linux-yu4c.site': 0.16; 'python;': 0.16; 'received:72.14.190': 0.16; 'received:72.14.190.87': 0.16; 'received:mail.wmmi.net': 0.16; 'received:wmmi.net': 0.16; 'reply-to:addr:awilliam': 0.16; 'reply- to:addr:whitemice.org': 0.16; 'workflow': 0.16; 'workflows': 0.16; 'mon,': 0.17; 'interesting.': 0.19; 'starts': 0.20; 'header:In- Reply-To:1': 0.21; 'seems': 0.21; "haven't": 0.22; 'issues.': 0.23; 'load': 0.24; 'code': 0.24; 'received:72.14': 0.26; 'testing': 0.27; 'example': 0.27; "i'm": 0.27; 'subject:?': 0.29; 'import': 0.29; 'sends': 0.29; '"in': 0.30; 'worker': 0.30; 'it.': 0.31; "didn't": 0.31; 'app': 0.32; 'does': 0.33; 'to:addr:python- list': 0.33; "isn't": 0.33; 'rather': 0.34; '...': 0.34; 'there': 0.35; '-0700,': 0.35; 'module.': 0.35; 'priority': 0.35; 'try:': 0.35; 'using': 0.35; 'platform': 0.36; 'setting': 0.36; 'uses': 0.36; 'another': 0.37; 'url:python': 0.38; 'anything': 0.38; 'url:org': 0.38; 'but': 0.38; 'subject:: ': 0.38; 'received:192': 0.38; 'header:Mime-Version:1': 0.39; 'to:addr:python.org': 0.39; 'allows': 0.40; 'received:192.168.1': 0.40; 'john': 0.62; 'our': 0.63; 'williams': 0.66; 'engine': 0.70; 'header:Reply-To:1': 0.72; 'reply-to:no real name:2**0': 0.72; 'average': 0.77; 'tidy': 0.84
Subject Re: Multiprocessing: don't push the pedal to the metal?
From Adam Tauno Williams <awilliam@whitemice.org>
To python-list@python.org
In-Reply-To <84e77cd9-9003-4053-a231-fe7d4bdbfef2@k15g2000pri.googlegroups.com>
References <644e4768-0fee-4c40-ba59-4b777b883884@z13g2000prk.googlegroups.com> <0211797f-e130-4bfa-bcb0-f701ec33c7b9@17g2000prr.googlegroups.com> <BANLkTi=AEW6TLwqcUmbiQ+NL8m9UDqhVLA@mail.gmail.com> <mailman.1967.1306145336.9059.python-list@python.org> <84e77cd9-9003-4053-a231-fe7d4bdbfef2@k15g2000pri.googlegroups.com>
Content-Type text/plain; charset="UTF-8"
Date Mon, 23 May 2011 16:46:34 -0400
Mime-Version 1.0
X-Mailer Evolution 2.32.1
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
Reply-To awilliam@whitemice.org
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.1987.1306183679.9059.python-list@python.org> (permalink)
Lines 37
NNTP-Posting-Host 82.94.164.166
X-Trace 1306183680 news.xs4all.nl 49182 [::ffff:82.94.164.166]:55821
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:6095

Show key headers only | View raw


On Mon, 2011-05-23 at 12:51 -0700, John Ladasky wrote:
> On May 23, 2:50 am, Adam Tauno Williams <awill...@whitemice.org>
> wrote:
> > I develop an app that uses multiprocessing heavily.  Remember that all
> > these processes are processes - so you can use all the OS facilities
> > regarding processes on them.  This includes setting nice values,
> > schedular options, CPU pinning, etc...
> That's interesting.  Does code exist in the Python library which
> allows the adjustment of CPU pinning and nice levels?  I just had
> another look at the multiprocessing docs, and also at os.subprocess.
> I didn't see anything that pertains to these issues.

"in the Python library" - no.  All these types of behaviors are platform
specific.

For example you can set the "nice" (priority) of a UNIX/LINUX process
using the nice method from the os module.  Our workflow engine does this
on all worker processes it starts - it sends the workers to the lowest
priority.


from os                    import nice as os_priority
...
        try:
            os_priority(20)
        except Exception, e:
            ...

I'm not aware of a tidy way to call sched_setaffinity from Python; but
my own testing indicates that the LINUX kernel is very good at figuring
this out on its own so long as it isn't swamped.  Queuing, rather than
starting, additional workflows if load average exceeds X.Y and setting
the process priority of workers to very-low seems to work very well.

There is <http://pypi.python.org/pypi/affinity> for setting affinity,
but I haven't used it.

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


Thread

Multiprocessing: don't push the pedal to the metal? John Ladasky <ladasky@my-deja.com> - 2011-05-21 20:58 -0700
  Re: Multiprocessing: don't push the pedal to the metal? John Ladasky <ladasky@my-deja.com> - 2011-05-22 14:06 -0700
    Re: Multiprocessing: don't push the pedal to the metal? Chris Angelico <rosuav@gmail.com> - 2011-05-23 10:32 +1000
    Re: Multiprocessing: don't push the pedal to the metal? Adam Tauno Williams <awilliam@whitemice.org> - 2011-05-23 05:50 -0400
      Re: Multiprocessing: don't push the pedal to the metal? John Ladasky <ladasky@my-deja.com> - 2011-05-23 12:51 -0700
        Re: Multiprocessing: don't push the pedal to the metal? Adam Tauno Williams <awilliam@whitemice.org> - 2011-05-23 16:46 -0400

csiph-web