这个代码是我按照教程写的,但是一老是报错
import time,random,Queue from multiprocessing.managers import BaseManager if __name__=="__main__": task_queue=Queue.Queue() result_queue=Queue.Queue() BaseManager.register("use_task_queue",callable=lambda:task_queue) BaseManager.register("use_result_queue",callable=lambda:result_queue) manager=BaseManager(address=("",5000),authkey="qqq") manager.start() task=manager.use_task_queue() result=manager.use_result_queue for i in range(10): n=random.randint(0,10000) print"put task %d ..."%n task.input(n) print "try get results..." for i in range(10): r=result.get(timeout=1) print "result =%s"%r manager.shutdown()
就是在manager.start()的时候出错的,有没有人指导一下哈
错误如下所示:
pickle.PicklingError: Can't pickle <function <lambda> at 0x024B95F0>: it's not f
ound as __main__.<lambda>
看到一篇文章说不能用lambad做callable函数