python多处理AttributeError:'str'对象没有属性'has'

时间:2016-05-11 13:13:58

标签: python-3.x multiprocessing threadpool

当我尝试使用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的新手,所以想知道这里发生了什么?

0 个答案:

没有答案