在python中使用Multiprocessing.Pool时出错

时间:2015-07-23 09:38:02

标签: python multiprocessing

我尝试了所有选项,但无法找到以下代码的问题,当我调用sub self.ProcessXmlFile(xml_file)时它会起作用,但是当我打印result_list时,多处理会抛出以下错误:

cPickle.PicklingError: Can't pickle <type 'instancemethod'>: attribute lookup __builtin__.instancemethod failed
            pool = multiprocessing.Pool(processes=4)
            result_list = []
            for xml_file in os.listdir(self.local_folder):
                    result_list.append(pool.apply_async(self.ProcessXmlFile, args = (xml_file,)))
            pool.close()
            pool.join()

0 个答案:

没有答案