我有以下问题:我想使用 pathos.multiprocessing 中的 amap。
import pathos as pt
class Foo:
def __init__(self):
pass
def f(self, a, b, c):
return a + b + c
def g(self):
pool = pt.multiprocessing.ProcessPool()
def _h(a, b, c):
k = self.f(a, b, c)
return k/2
result = [pool.amap(_h, (i, j, k)) for i in range(3) for j in range(5) for k in range(7)]
return result
a = Foo()
b = a.g()
b[0].get()
尽管我可以在 f 中做任何事情,但必须有这两个函数 f 和 g。
如果我运行此代码,我会得到 g 需要 3 个参数,但给出了一个。
TypeError: _h() takes exactly 3 arguments (1 given)
我怎样才能解决这个问题?