I've run into a bit of a wall here, so I'm going to do my best to explain the issue.
def playGames(jobQueue, ...):
nextJob = jobQueue.get()
def runPool(fens, timesetting, ...):
for fen in fens:
if __name__ == '__main__':
Job = collections.namedtuple('Job', 'gamefen timecontrol')
playGames(jobQueue, ...) # jobQueue is a multiprocess.Queue() object
"'module' object has no attribute 'Job'"
Traceback (most recent call last):
File "c:\Python27\lib\multiprocessing\process.py", line 258, in _bootstrap
File "c:\Python27\lib\multiprocessing\process.py", line 114, in run
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'
On Windows, the implementation of multiprocessing places additional constraints on code - effectively what happens is a different python interpreter is started for each process, and then these new interpreters load the python code as non-main - so, to use Job, the non-main processes need to have Job defined outside the
if __name__=='__main__' conditional statement. See heading 22.214.171.124 below https://docs.python.org/2/library/multiprocessing.html