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


Groups > comp.lang.python > #18680

Re: Parallel Processing

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!txtfeed1.tudelft.nl!tudelft.nl!txtfeed2.tudelft.nl!amsnews11.chello.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <d@davea.name>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'parameter': 0.05; 'function,': 0.07; 'statements,': 0.07; '0),': 0.09; 'arguments,': 0.09; 'globals': 0.09; 'indicates': 0.09; 'nameerror:': 0.09; 'statement.': 0.09; 'subject:Processing': 0.09; 'worked,': 0.09; 'am,': 0.12; 'things.': 0.12; 'def': 0.13; 'skip:" 40': 0.15; '"global"': 0.16; '(),': 0.16; '(0,': 0.16; '0))': 0.16; 'globals.': 0.16; 'pygame.': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.18; 'simpler': 0.18; 'seems': 0.20; 'cc:no real name:2**0': 0.20; '(most': 0.21; 'header:In-Reply-To:1': 0.22; 'values.': 0.23; 'defined': 0.24; 'cc:2**0': 0.24; 'library.': 0.24; 'traceback': 0.24; 'creating': 0.25; 'handles': 0.25; 'code': 0.25; 'function': 0.27; 'separate': 0.28; 'process,': 0.28; 'print': 0.29; 'cc:addr:python.org': 0.29; 'error': 0.29; 'skip:p 30': 0.29; "it'd": 0.30; 'values': 0.32; 'list': 0.32; "can't": 0.32; 'header:User-Agent:1': 0.33; 'probably': 0.34; 'calling': 0.34; 'anything': 0.34; 'be,': 0.34; 'function.': 0.34; 'last):': 0.34; 'file': 0.36; 'starting': 0.36; 'two': 0.37; 'but': 0.37; 'run': 0.37; 'received:192': 0.37; 'some': 0.38; 'screen': 0.38; 'first.': 0.39; "i'd": 0.39; 'else': 0.39; 'called': 0.40; 'missing': 0.40; 'might': 0.40; 'move': 0.40; 'received:192.168': 0.40; 'your': 0.61; 'website': 0.65; 'share': 0.66; 'making': 0.67; 'supply': 0.69; 'header:Reply-To:1': 0.71; 'reply-to:no real name:2**0': 0.72; 'have.': 0.77; 'experiment': 0.84; 'timer': 0.84
Date Sun, 08 Jan 2012 17:02:21 -0500
From Dave Angel <d@davea.name>
User-Agent Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20110922 Thunderbird/3.1.15
MIME-Version 1.0
To Yigit Turgut <y.turgut@gmail.com>
Subject Re: Parallel Processing
References <25422fc4-b2ba-41aa-b12a-5e2fdc989bab@j9g2000vby.googlegroups.com> <mailman.4524.1326033306.27778.python-list@python.org> <402bb451-9986-4a26-b606-6a1c3429f98e@s18g2000vby.googlegroups.com> <mailman.4525.1326038463.27778.python-list@python.org> <3161f7ec-feb6-41ef-b73d-bb22e3e7704e@n6g2000vbg.googlegroups.com>
In-Reply-To <3161f7ec-feb6-41ef-b73d-bb22e3e7704e@n6g2000vbg.googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Provags-ID V02:K0:f2WbouGxm5feR2jmiXV9+H1jrrLbiGQvY9oQmVodqGL b63BxwPjldzkqRIr01ddjev3qsPJvpB5pl0dKBk8At5M24GVjN cNH+hUH9dbuXs40ExV32fXDaQhMpfDKs64+rF/d/Y2O0fNoIHQ 8DHryowikoTSqdKQQtqWiwpo1MZ68tBCVuviWw2WPT8ayxvDxh TaHkuDdUdLsm+3wEVUmf0lpstgtTxGs7XTWzfEOl4PZidjNQDZ vGJhIg+ZDar2vfsmD2Zka0cElatExgffWU8i441xbzf9FBnxX0 9xGVwbTH7Kh2xy/bwvGd+sl8+XbY2CNfMA9BvCjYbOsjGsYK/P r94wwqAaMXLRe0BSF/D8=
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
Reply-To d@davea.name
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.4530.1326060156.27778.python-list@python.org> (permalink)
Lines 84
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1326060156 news.xs4all.nl 6924 [2001:888:2000:d::a6]:55459
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:18680

Show key headers only | View raw


On 01/08/2012 11:39 AM, Yigit Turgut wrote:
>
> screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
> timer = pygame.time.Clock()
> white = True
> start = time.time()
> end = time.time() - start
> end2= time.time() - start
>
> def test1():
>    global end
>    global white
>    while(end<5):
>      end = time.time() - start
>      timer.tick(4) #FPS
>      screen.fill((255,255,255) if white else (0, 0, 0))
>      white = not white
>      pygame.display.update()
>
> def test2():
>    global end2
>    while(end2<5):
>      end2 = time.time() - start
>      print end2
>
> ppservers = ()
> job_server = pp.Server(ppservers=ppservers)
>
> job1 = job_server.submit(test1, (), globals=globals())
> job2 = job_server.submit(test2, (), globals=globals())
> result = job1()
> result2 = job2()
>
> print  result2
>
> job_server.print_stats()
>
> This *supposed to* print values of 'end' and simultaneously execute
> test1. Eventhough I set globals parameter and nothing seems to be
> wrong this code generates the following traceback ;
>
> Starting pp with 2 workers
> An error has occured during the function execution
> Traceback (most recent call last):
>    File "/usr/lib/python2.6/site-packages/ppworker.py", line 90, in run
>      __result = __f(*__args)
>    File "<string>", line 4, in test1
> NameError: global name 'end' is not defined
> An error has occured during the function execution
> Traceback (most recent call last):
>    File "/usr/lib/python2.6/site-packages/ppworker.py", line 90, in run
>      __result = __f(*__args)
>    File "<string>", line 3, in test2
> NameError: global name 'end2' is not defined
>
> How can this be, what am I missing ?
I don't see anything on the http://www.parallelpython.com 
<http://www.parallelpython.com/> website that indicates how it handles 
globals.  Remember this is creating a separate process, so it can't 
literally share the globals you have.  i would have expected it to 
pickle them when you say globals=globals(), but I dunno. In any case, I 
can't see any value in making end global with the "global" statement.  
I'd move the end= line inside the function, and forget about making it 
global.

The other thing you don't supply is a list of functions that might be 
called by your function.  See the depfuncs argument.  It probably 
handles all the system libraries, but I can't see how it'd be expected 
to handle pygame.

With the limited information supplied by the website, I'd experiment 
first with simpler things.  Make two functions that are self-contained, 
and try them first.  No global statements, and no calls to pygame.  
After that much worked, then I'd try adding arguments, and then return 
values.

Then i'd try calling separate functions (declaring them in depfuncs).  
And finally I'd try some 3rd party library.


-- 

DaveA

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


Thread

Parallel Processing Yigit Turgut <y.turgut@gmail.com> - 2012-01-08 05:23 -0800
  Re: Parallel Processing Dave Angel <d@davea.name> - 2012-01-08 09:34 -0500
    Re: Parallel Processing Yigit Turgut <y.turgut@gmail.com> - 2012-01-08 07:45 -0800
      Re: Parallel Processing Chris Angelico <rosuav@gmail.com> - 2012-01-09 03:00 +1100
        Re: Parallel Processing Yigit Turgut <y.turgut@gmail.com> - 2012-01-08 08:39 -0800
          Re: Parallel Processing Dave Angel <d@davea.name> - 2012-01-08 17:02 -0500

csiph-web