【发布时间】:2016-08-01 04:47:28
【问题描述】:
我在这里遇到了一些障碍,所以我会尽力解释这个问题。
def playGames(jobQueue, ...):
....
nextJob = jobQueue.get()
...
def runPool(fens, timesetting, ...):
...
for fen in fens:
jobQueue.put(Job(gamefen=fen, timecontrol=timesetting))
...
if __name__ == '__main__':
Job = collections.namedtuple('Job', 'gamefen timecontrol')
...
...
playGames(jobQueue, ...) # jobQueue is a multiprocess.Queue() object
运行后,抛出以下错误。
"'module' object has no attribute 'Job'"
所以我将 Job = collections... 行移到了 if name==main 的上方,并且成功了!
但是,在我的 Ubuntu 系统上,没有 Job = collections...moved 的代码编写方式可以正常工作。
所以windows7使用python2.7.8就不行了 Ubuntu14 使用 python2.7.6 它确实有效 Ubuntu14 使用 python3.4.3 确实可以工作
我一定是错过了什么……
完整的追溯在这里:
Traceback (most recent call last):
File "c:\Python27\lib\multiprocessing\process.py", line 258, in _bootstrap
self.run()
File "c:\Python27\lib\multiprocessing\process.py", line 114, in run
self._target(*self._args, **self._kwargs)
File "c:\Users\Andy\Desktop\Github\LucasZinc\Zinc.py", line 338, in play_games
_job = jobQueue.get()
File "c:\Python27\lib\multiprocessing\queues.py", line 117, in get
res = self._recv()
AttributeError: 'module' object has no attribute 'Job'
【问题讨论】:
-
请显示完整的错误信息和完整的回溯。
-
添加了回溯
标签: python collections queue namedtuple