1

I have had multiple problems trying to use PP. I am running python2.6 and pp 1.6.0 rc3. Using the following test code:

import pp
nodes=('mosura02','mosura03','mosura04','mosura05','mosura06',
       'mosura09','mosura10','mosura11','mosura12')

def pptester():
        js=pp.Server(ppservers=nodes)
        tmp=[]
        for i in range(200):
                tmp.append(js.submit(ppworktest,(),(),('os',)))
        return tmp

def ppworktest():
        return os.system("uname -a")

gives me the following result:

In [10]: Exception in thread run_local:
Traceback (most recent call last):
  File "/usr/lib64/python2.6/threading.py", line 525, in __bootstrap_inner
    self.run()
  File "/usr/lib64/python2.6/threading.py", line 477, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/home/wkerzend/python_coala/lib/python2.6/site-packages/pp.py", line 751, in _run_local
    job.finalize(sresult)
UnboundLocalError: local variable 'sresult' referenced before assignment

Exception in thread run_local:
Traceback (most recent call last):
  File "/usr/lib64/python2.6/threading.py", line 525, in __bootstrap_inner
    self.run()
  File "/usr/lib64/python2.6/threading.py", line 477, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/home/wkerzend/python_coala/lib/python2.6/site-packages/pp.py", line 751, in _run_local
    job.finalize(sresult)
UnboundLocalError: local variable 'sresult' referenced before assignment

Exception in thread run_local:
Traceback (most recent call last):
  File "/usr/lib64/python2.6/threading.py", line 525, in __bootstrap_inner
    self.run()
  File "/usr/lib64/python2.6/threading.py", line 477, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/home/wkerzend/python_coala/lib/python2.6/site-packages/pp.py", line 751, in _run_local
    job.finalize(sresult)
UnboundLocalError: local variable 'sresult' referenced before assignment

Exception in thread run_local:
Traceback (most recent call last):
  File "/usr/lib64/python2.6/threading.py", line 525, in __bootstrap_inner
    self.run()
  File "/usr/lib64/python2.6/threading.py", line 477, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/home/wkerzend/python_coala/lib/python2.6/site-packages/pp.py", line 751, in _run_local
    job.finalize(sresult)
UnboundLocalError: local variable 'sresult' referenced before assignment

Any help is greatly appreciated.

Amro
  • 123,847
  • 25
  • 243
  • 454
Wolfgang Kerzendorf
  • 724
  • 1
  • 9
  • 24
  • I don't know PP, but given that the exception happens deep in the library, it's probably a bug. As long as your code above conforms to whatever API PP specifies. Try up- or downgrading PP and see what happens perhaps... – Jakob Borg Apr 11 '10 at 06:40

2 Answers2

2

I can't read your code because it's not formatted properly, but I can tell you your exact problem: you're trying to modify a global variable named "sresult" from inside a function, but you did not add this line to the beginning of your function:

global sresult

If you don't declare a variable global, Python will assume it's local to the function if you try to assign it within the function, so when you try to modify or access it, Python will complain that you haven't yet "bound the local variable" (that is, assigned it or given it a value).

jemfinch
  • 2,851
  • 19
  • 24
  • Well, yes I know that this is problem. What my question was about is that there's a problem in the parallel-python package and was wondering if anyone has found a fix or knows what to do about it. Thanks for answering however. Wolfgang – Wolfgang Kerzendorf Apr 11 '10 at 06:42
  • Thanks for the answer. I was perplexed by the problem. – tshepang Oct 04 '10 at 07:57
0

It's a bug in the pp library. Fix it, or wait for it to be fixed.

Bite code
  • 578,959
  • 113
  • 301
  • 329