多处理TypeError:无法腌制_thread.lock对象

时间:2018-11-30 03:36:42

标签: python-3.x multithreading pool

当我在python3上运行它时,出现错误:TypeError:无法腌制_thread.lock对象 例:     导入时间     导入多处理     从多处理导入Process,freeze_support,Manager,Queue,Pool     q =队列()     游泳池=游泳池(3)     A类(对象):         def init (自我,varam):             self.varam = varam

class class_one(object):
    def __init__(self):
        self.var = {}
        self.list = []
        self.get()
    def get_result(self, varam):
        q.put(A(varam))
    def get(self):
        for i in [6,7,8,9]:
            self.list.append(pool.apply_async(self.get_result, (i, )))
            #p = Process(target=self.get_result, args=(i, ))
            #process_list.append(p)
            #p.start()
        pool.close()
        pool.join()

if __name__ == '__main__':
    freeze_support()
    process_num =2
    process_list = []
    g = class_one()

    for i in g.list:
        print(i.get())
    # for j in process_list:
    #     j.join()
    # print(q.qsize())
    # if q.empty():
    #     print("error")
    # while (not q.empty()):
    #     print(q.get().varam)
    #     g.var[q.get().varam]=q.get()

0 个答案:

没有答案