from multiprocessing import Pool
class A:
def __init__(self, n):
self.n = n
def __foo(self, i):
return i + 1
def bar(self):
l = list(map(self.__foo, range(self.n)))
print(len(l))
def baz(self):
pool = Pool(2)
l = list(pool.map(self.__foo, range(self.n)))
print(len(l))
a = A(3)
a.bar()
a.baz()
这是简短的输出:
3
AttributeError: 'A' object has no attribute '__foo'
我想用它Pool来处理一个大的dataframe,但Pool.map不起作用——如何处理它?
慕斯王
相关分类