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


Groups > comp.lang.python > #2658

Re: Multiprocessing, shared memory vs. pickled copies

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.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; 'bug': 0.02; 'python.': 0.05; 'arguments': 0.05; 'imports': 0.07; 'python': 0.07; 'machines.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'underlying': 0.09; 'pm,': 0.11; 'output': 0.12; 'extension': 0.14; 'wrote:': 0.14; 'starts': 0.15; 'bit.': 0.16; 'enigma': 0.16; 'kern': 0.16; 'received:216.62': 0.16; 'received:216.62.213': 0.16; 'received:enthought.com': 0.16; 'subject:memory': 0.16; 'subject:vs.': 0.16; 'allocated': 0.19; 'exists': 0.19; 'interpret': 0.19; 'yet.': 0.19; 'seems': 0.21; '(which': 0.21; 'header:In-Reply-To:1': 0.22; "aren't": 0.22; '(and': 0.22; 'short,': 0.23; 'suggests': 0.23; 'objects': 0.24; 'memory': 0.24; 'version': 0.25; 'properly': 0.25; "i'm": 0.26; "i'll": 0.26; 'pass': 0.27; 'function': 0.27; 'looks': 0.28; 'beyond': 0.28; 'shared': 0.29; 'bugs': 0.29; 'fine.': 0.29; 'least': 0.30; 'arrays': 0.31; 'at.': 0.31; 'objects.': 0.31; 'types.': 0.31; 'however,': 0.31; 'to:addr:python-list': 0.32; 'implemented': 0.33; 'things': 0.33; 'module': 0.33; 'connection': 0.33; 'uses': 0.34; 'header:X-Complaints-To:1': 0.34; 'post': 0.34; 'regular': 0.34; 'header:User-Agent:1': 0.35; 'defining': 0.35; 'error.': 0.36; 'getting': 0.36; 'think': 0.36; 'data': 0.37; 'should': 0.37; 'but': 0.38; 'url:org': 0.38; 'used': 0.38; 'received:org': 0.38; 'though': 0.38; 'much.': 0.39; 'to:addr:python.org': 0.39; 'header:Mime-Version:1': 0.39; 'works': 0.40; 'attempt': 0.40; 'header:Received:5': 0.40; 'back': 0.61; 'our': 0.63; 'world': 0.65; 'subject:. ': 0.66; 'believe': 0.66; 'guarantee': 0.75; 'eco': 0.84; 'mechanism.': 0.84; 'inheritance,': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Robert Kern <robert.kern@gmail.com>
Subject Re: Multiprocessing, shared memory vs. pickled copies
Date Tue, 05 Apr 2011 10:47:17 -0500
Organization The Church of Last Thursday
References <6ace38dc-33c6-44ab-a17a-084d62d666cb@w9g2000prg.googlegroups.com> <indmcg$vin$1@dough.gmane.org>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host outbound.enthought.com
User-Agent Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9
In-Reply-To <indmcg$vin$1@dough.gmane.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
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.50.1302018455.9059.python-list@python.org> (permalink)
Lines 41
NNTP-Posting-Host 82.94.164.166
X-Trace 1302018455 news.xs4all.nl 65870 [::ffff:82.94.164.166]:54242
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:2658

Show key headers only | View raw


On 4/4/11 7:05 PM, Robert Kern wrote:
> On 4/4/11 3:20 PM, John Ladasky wrote:

> However, at least in Python 2.7, multiprocessing seems to have a C extension
> module defining the Connection objects. Unfortunately, it looks like this C
> extension just imports the regular pickler that is not aware of these custom
> types. That's why you get this error. I believe this is a bug in Python.
>
> So what did you try, and what output did you get? What version of Python are you
> using?
>
>> I think that my understanding of multiprocessing
>> needs to evolve beyond the use of Pool, but I'm not sure yet. This
>> post suggests as much.
>>
>> http://mail.scipy.org/pipermail/scipy-user/2009-February/019696.html
>
> Maybe. If the __reduce_ex__() method is implemented properly (and
> multiprocessing bugs aren't getting in the way), you ought to be able to pass
> them to a Pool just fine. You just need to make sure that the shared arrays are
> allocated before the Pool is started. And this only works on UNIX machines. The
> shared memory objects that shmarray uses can only be inherited. I believe that's
> what Sturla was getting at.

I'll take that back a little bit. Since the underlying shared memory types can 
only be shared by inheritance, the ForkingPickler is only used for the arguments 
passed to Process(), and not used for things sent through Queues (which Pool 
uses). Since Pool cannot guarantee that the data exists before the Pool starts 
its subprocesses, it must use the general mechanism.

So in short, if you pass the shmarrays as arguments to the target function in 
Process(), it should work fine.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco

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


Thread

Multiprocessing, shared memory vs. pickled copies John Ladasky <ladasky@my-deja.com> - 2011-04-04 13:20 -0700
  Re: Multiprocessing, shared memory vs. pickled copies Philip Semanchuk <philip@semanchuk.com> - 2011-04-04 19:34 -0400
    Re: Multiprocessing, shared memory vs. pickled copies John Ladasky <ladasky@my-deja.com> - 2011-04-05 09:58 -0700
      Re: Multiprocessing, shared memory vs. pickled copies Philip Semanchuk <philip@semanchuk.com> - 2011-04-05 13:43 -0400
        Re: Multiprocessing, shared memory vs. pickled copies John Ladasky <ladasky@my-deja.com> - 2011-04-06 23:40 -0700
          Re: Multiprocessing, shared memory vs. pickled copies John Ladasky <ladasky@my-deja.com> - 2011-04-07 00:41 -0700
            Re: Multiprocessing, shared memory vs. pickled copies Philip Semanchuk <philip@semanchuk.com> - 2011-04-07 09:23 -0400
          Re: Multiprocessing, shared memory vs. pickled copies Robert Kern <robert.kern@gmail.com> - 2011-04-07 12:44 -0500
            Re: Multiprocessing, shared memory vs. pickled copies John Ladasky <ladasky@my-deja.com> - 2011-04-07 11:39 -0700
              Re: Multiprocessing, shared memory vs. pickled copies Robert Kern <robert.kern@gmail.com> - 2011-04-07 15:01 -0500
  Re: Multiprocessing, shared memory vs. pickled copies Robert Kern <robert.kern@gmail.com> - 2011-04-04 19:05 -0500
    Re: Multiprocessing, shared memory vs. pickled copies sturlamolden <sturlamolden@yahoo.no> - 2011-04-07 16:39 -0700
  Re: Multiprocessing, shared memory vs. pickled copies Philip Semanchuk <philip@semanchuk.com> - 2011-04-04 21:16 -0400
  Re: Multiprocessing, shared memory vs. pickled copies Robert Kern <robert.kern@gmail.com> - 2011-04-05 10:47 -0500
  Re: Multiprocessing, shared memory vs. pickled copies sturlamolden <sturlamolden@yahoo.no> - 2011-04-07 17:03 -0700
    Re: Multiprocessing, shared memory vs. pickled copies sturlamolden <sturlamolden@yahoo.no> - 2011-04-07 17:38 -0700
      Re: Multiprocessing, shared memory vs. pickled copies sturlamolden <sturlamolden@yahoo.no> - 2011-04-07 18:10 -0700
        Re: Multiprocessing, shared memory vs. pickled copies John Ladasky <ladasky@my-deja.com> - 2011-04-09 00:36 -0700
          Re: Multiprocessing, shared memory vs. pickled copies sturlamolden <sturlamolden@yahoo.no> - 2011-04-09 10:15 -0700
            Re: Multiprocessing, shared memory vs. pickled copies John Ladasky <ladasky@my-deja.com> - 2011-04-09 13:18 -0700
              Re: Multiprocessing, shared memory vs. pickled copies sturlamolden <sturlamolden@yahoo.no> - 2011-04-10 08:01 -0700
        Re: Multiprocessing, shared memory vs. pickled copies sturlamolden <sturlamolden@yahoo.no> - 2011-04-10 15:35 -0700

csiph-web