1

以下代码:

from pathos.multiprocessing import ProcessingPool as Pool
list1 = [1,2,3,4,5]
list2 = [6,7,8,9,10]
def function1(x,y):
    print x
    print y
if __name__ == '__main__':
    pool = Pool(5)
    pool.map(function1, list1, list2)

它得到以下错误:

Traceback (most recent call last):
  File "test.py", line 9, in <module>
    pool.map(function1, list1, list2)
  File "C:\Python27\lib\site-packages\pathos\multiprocessing.py", line 136, in map
    return _pool.map(star(f), zip(*args)) # chunksize
  File "C:\Python27\lib\site-packages\multiprocess\pool.py", line 251, in map
    return self.map_async(func, iterable, chunksize).get()
  File "C:\Python27\lib\site-packages\multiprocess\pool.py", line 567, in get
    raise self._value
cPickle.PicklingError: Can't pickle <type 'function'>: attribute lookup __builtin__.function failed

pathos.multiprocessing 不是旨在解决这个问题吗?

4

0 回答 0