我有一段类似于以下Python代码:
procs = cpu_count()-1
if serial or procs == 1:
results = map(do_experiment, experiments)
else:
pool = Pool(processes=procs)
results = pool.map(do_experiment, experiments)
当我设置 serial
标志时,它运行良好,但是在使用 Pool
时会出现以下错误。 当我尝试从 do_experiment
打印一些东西时,没有任何显示,因此我无法在那里尝试/捕获并打印堆栈跟踪。
Exception in thread Thread-2:
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 530, in __bootstrap_inner
self.run()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 483, in run
self.__target(*self.__args, **self.__kwargs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/pool.py", line 285, in _handle_tasks
put(task)
TypeError: 'NoneType' object is not callable
什么是处理调试的好方法?
cpu_count()
的返回值是什么? - mgilsonpool.map
代替map
,事情都会出错。 - noio