我使用python 2.7。 下面是一些我的代码:
from pathos.multiprocessing import ProcessingPool as Pool
class pair_scraper(object):
#code and various methods ...
def parallelized_processing(self):
'''
Parallelize length extraction of
relevant files.
'''
pool = Pool(self.pool_size)
pool.map(self.length_processer, self.zip_files)
pool.close()
pool.join()
然而,当我运行它,我得到了一个空白AssertionError
:
/...file.py in parallelized_processing(self)
69 '''
70 pool = Pool(self.pool_size)
---> 71 pool.map(self.length_processer, self.zip_files)
72 # pool.close()
73 # pool.join()
/.../anaconda/lib/python2.7/site-packages/pathos/multiprocessing.pyc in map(self, f, *args, **kwds)
134 AbstractWorkerPool._AbstractWorkerPool__map(self, f, *args, **kwds)
135 _pool = self._serve()
--> 136 return _pool.map(star(f), zip(*args)) # chunksize
137 map.__doc__ = AbstractWorkerPool.map.__doc__
138 def imap(self, f, *args, **kwds):
/.../anaconda/lib/python2.7/site-packages/multiprocess/pool.pyc in map(self, func, iterable, chunksize)
248 Equivalent of `map()` builtin
249 '''
--> 250 assert self._state == RUN
251 return self.map_async(func, iterable, chunksize).get()
252
AssertionError:
这个错误似乎像描述的一个在这个问题上 ,虽然修复有比较明显的。 我跑了上面的代码去除pool.close()
和pool.join()
但得到了同样的结果。
思考?