18
多重处理:如何在类中定义的函数上使用Pool.map?
当我运行类似: from multiprocessing import Pool p = Pool(5) def f(x): return x*x p.map(f, [1,2,3]) 它工作正常。但是,将其作为类的函数: class calculate(object): def run(self): def f(x): return x*x p = Pool() return p.map(f, [1,2,3]) cl = calculate() print cl.run() 给我以下错误: Exception in thread Thread-1: Traceback (most recent call last): File "/sw/lib/python2.6/threading.py", line 532, in __bootstrap_inner …