Minor fix to evaluate with _return in ProcPool execution.

This commit is contained in:
Griatch 2012-09-03 23:47:50 +02:00
parent 5348563bfb
commit d1e0836d23

View file

@ -84,8 +84,6 @@ class ProcPoolChild(AMPChild):
""" """
import ev, utils
class Ret(object): class Ret(object):
"Helper class for holding returns from exec" "Helper class for holding returns from exec"
def __init__(self): def __init__(self):
@ -102,9 +100,7 @@ class ProcPoolChild(AMPChild):
return to_pickle(self.returns, emptypickle=False) or "" return to_pickle(self.returns, emptypickle=False) or ""
_return = Ret() _return = Ret()
available_vars = {'ev':ev, available_vars = {'_return':_return}
'inherits_from':utils.inherits_from,
'_return':_return}
if environment: if environment:
# load environment # load environment
try: try:
@ -118,7 +114,7 @@ class ProcPoolChild(AMPChild):
# try to execute with eval first # try to execute with eval first
try: try:
ret = eval(source, {}, available_vars) ret = eval(source, {}, available_vars)
ret = to_pickle(ret, emptypickle=False) or "" ret = _return.get_returns() or to_pickle(ret, emptypickle=False) or ""
except Exception: except Exception:
# use exec instead # use exec instead
exec source in available_vars exec source in available_vars