PicklingError: Can't pickle : attribute lookup thread.lock failed

錯誤原因:使用隊列錯誤(Queue.Queue()不能用於進程間通信)
當子進程執行的方法定義在類中時會報錯:PicklingError: Can't pickle <type 'instancemethod'>: attribute lookup __builtin__.instancemethod failed

def main():
    manager = multiprocessing.Manager()
    queue = manager.Queue()
    state_queue = manager.Queue(maxsize=1)
    pool = Pool()
    state_queue.put({})
    A  = CreateIndex(queue,state_queue)
    A.run()
    state_list = []
    for i in range(5):
        try:
            result = pool.apply_async(testRun, args = (queue,state_queue))
            state_list.append(result)
        except:
            errmsg = get_err_msg()
            log.root.error(errmsg)
    pool.close()
    pool.join()
    if result.successful():
        print 'successful'


發佈了44 篇原創文章 · 獲贊 10 · 訪問量 15萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章