当我尝试使用multiprocessing
模块时,Python
生成了以下错误,
AttributeError: 'str' object has no attribute 'has'
使用multiprocessing
的代码是,
import multiprocessing
p = multiprocessing.Pool(max_processes)
p.map(worker_function, input_data) # trigger the error
它追溯到Pool class
,
def map(self, func, iterable, chunksize=None):
'''
Apply `func` to each element in `iterable`, collecting the results
in a list that is returned.
'''
return self._map_async(func, iterable, mapstar, chunksize).get() # error traced to here
最终追溯到(仍在class Pool
),
def get(self, timeout=None):
self.wait(timeout)
if not self.ready():
raise TimeoutError
if self._success:
return self._value
else:
raise self._value # error pointes to here
input_data
是继承dict
的类的实例。
我是multiprocessing
的新手,所以想知道这里发生了什么?