views:

199

answers:

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.

+1  A: 

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
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
Thanks for the answer. I was perplexed by the problem.
Tshepang