multiprocessing 的子进程错误完全没有错误提示,要怎样才能 debug 呢 ?
环境是 windows python 2.7
例如下面这段带码
#-*-coding:utf-8-*- import multiprocessing from multiprocessing import Pool,Process,Queue import time import pdb def add(i,item,queue): item["i"] = i queue.put(item) def store(queue): time.sleep(1) while True: print queue.get() if __name__ == "__main__": item = {} manager = multiprocessing.Manager() queue = manager.Queue() pool = Pool() pool.apply_async(store,args = (queue,)) try: for i in range(10): pool.apply_async( add, args = (i,item,queue,"这里多了个参数但没任何错误提示")) #pool.apply_async( add, args = (i,item,queue)) #这样可以正常运行 except Exception,e: print Exception,":",e time.sleep(2) pool.terminate() pool.join()
1
GeekGao 2016-10-26 14:54:32 +08:00
没执行到 add 方法里啊,你 apply_async 调用过后.get() 执行后就知道有报错了啊
|