Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!news-transit.tcx.org.uk!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.kpn.net!pfeed08.wxs.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'wed,': 0.04; '-0700': 0.07; 'function,': 0.07; 'wrapper': 0.07; 'after,': 0.09; 'to:name:python list': 0.09; 'pm,': 0.11; 'def': 0.13; 'cc:': 0.14; 'modify': 0.14; 'wrote:': 0.14; 'guys,': 0.16; 'it).': 0.16; 'numpy': 0.16; 'objects?': 0.16; 'received:mindspring.com': 0.16; 'simplified': 0.16; 'object,': 0.19; 'header:In-Reply-To:1': 0.22; '(but': 0.22; 'matter,': 0.23; 'runs': 0.24; 'example': 0.24; 'checked': 0.25; "i'm": 0.26; '(in': 0.27; 'object': 0.27; 'url:mailman': 0.27; 'function': 0.27; 'date:': 0.28; "doesn't": 0.28; 'thanks': 0.29; 'shared': 0.29; 'hi,': 0.29; 'list': 0.30; 'do.': 0.31; 'extremely': 0.31; 'arrays': 0.31; 'basically,': 0.31; 'turns': 0.31; 'random': 0.31; 'sharing': 0.31; 'url:library': 0.31; 'import': 0.32; 'to:addr:python-list': 0.32; 'url:listinfo': 0.33; 'url:docs': 0.33; 'execution': 0.33; 'subject:': 0.33; 'several': 0.33; 'updated': 0.33; 'there': 0.35; 'print': 0.35; 'charset:us-ascii': 0.36; 'some': 0.37; 'however': 0.37; 'should': 0.37; 'url:python': 0.37; 'run': 0.37; 'apr': 0.38; 'parallel': 0.38; 'thread': 0.38; 'but': 0.38; 'url:org': 0.38; 'current': 0.38; 'to:addr:python.org': 0.39; 'from:': 0.39; 'header:Mime-Version:1': 0.39; 'received:24': 0.39; 'works': 0.40; 'would': 0.40; 'give': 0.61; 'order': 0.61; 'header:Message-Id:1': 0.62; '2011': 0.62; 'here': 0.65; 'response.': 0.67; 'email addr:hotmail.com': 0.71; 'received:69.73': 0.84 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Apple Message framework v1082) Subject: Re: multiprocessing From: Philip Semanchuk In-Reply-To: Date: Thu, 7 Apr 2011 21:05:23 -0400 Content-Transfer-Encoding: quoted-printable References: <75a6974b-d954-4528-8bbc-9ab7b6b8b80b@f11g2000vbx.googlegroups.com>, To: Python list X-Mailer: Apple Mail (2.1082) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - deimos.nocdirect.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - semanchuk.com X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 123 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1302224730 news.xs4all.nl 34849 [::ffff:82.94.164.166]:33117 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:2820 On Apr 7, 2011, at 8:57 PM, Kerensa McElroy wrote: >=20 > Hi, >=20 > thanks for your response. >=20 > I checked out multiprocessing.value, however from what I can make out, = it works with object of only a very limited type. Is there a way to do = this for more complex objects? (In reality, my object is a large = multi-dimensional numpy array). Elsa,=20 Are you following the current thread in this list which is talking about = sharing numpy arrays via multiprocessing? http://mail.python.org/pipermail/python-list/2011-April/1269173.html > Date: Wed, 6 Apr 2011 22:20:06 -0700 > Subject: Re: multiprocessing > From: drsalists@gmail.com > To: kerensaelise@hotmail.com > CC: python-list@python.org >=20 >=20 > On Wed, Apr 6, 2011 at 9:06 PM, elsa wrote: >=20 > Hi guys, >=20 >=20 >=20 > I want to try out some pooling of processors, but I'm not sure if it >=20 > is possible to do what I want to do. Basically, I want to have a >=20 > global object, that is updated during the execution of a function, and >=20 > I want to be able to run this function several times on parallel >=20 > processors. The order in which the function runs doesn't matter, and >=20 > the value of the object doesn't matter to the function, but I do want >=20 > the processors to take turns 'nicely' when updating the object, so >=20 > there are no collisions. Here is an extremely simplified and trivial >=20 > example of what I have in mind: >=20 >=20 >=20 > from multiprocessing import Pool >=20 > import random >=20 >=20 >=20 > p=3DPool(4) >=20 > myDict=3D{} >=20 >=20 >=20 > def update(value): >=20 > global myDict >=20 > index=3Drandom.random() >=20 > myDict[index]+=3Dvalue >=20 >=20 >=20 > total=3D1000 >=20 >=20 >=20 > p.map(update,range(total)) >=20 >=20 >=20 >=20 >=20 > After, I would also like to be able to use several processors to >=20 > access the global object (but not modify it). Again, order doesn't >=20 > matter: >=20 >=20 >=20 > p1=3DPool(4) >=20 >=20 >=20 > def getValues(index): >=20 > global myDict >=20 > print myDict[index] >=20 >=20 >=20 > p1.map(getValues,keys.myDict) >=20 >=20 >=20 > Is there a way to do this=20 > This should give you a synchronized wrapper around an object in shared = memory: >=20 > = http://docs.python.org/library/multiprocessing.html#multiprocessing.Value >=20 >=20 > --=20 > http://mail.python.org/mailman/listinfo/python-list