1
votes

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.

2
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

2 Answers

2
votes

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).

0
votes

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