使用多处理Pool.map()时不能class=‘class 3’>选择
multiprocessing
Pool.map()
import multiprocessingdef f(x): return x*xdef go(): pool = multiprocessing.Pool(processes=4) print pool.map(f, range(10))if __name__== '__main__' : go()
PicklingError: Can't pickle <type 'instancemethod'>: attribute lookup __builtin__.instancemethod failed
import someClassif __name__== '__main__' : sc = someClass.someClass() sc.go()
someClass
import multiprocessingclass someClass(object): def __init__(self): pass def f(self, x): return x*x def go(self): pool = multiprocessing.Pool(processes=4) print pool.map(self.f, range(10))
一只斗牛犬
相关分类