88 initialTasks = 2 * NumberOfProcesses |
88 initialTasks = 2 * NumberOfProcesses |
89 for task in argumentsList[:initialTasks]: |
89 for task in argumentsList[:initialTasks]: |
90 taskQueue.put(task) |
90 taskQueue.put(task) |
91 |
91 |
92 # Start worker processes |
92 # Start worker processes |
93 for i in range(NumberOfProcesses): |
93 for _ in range(NumberOfProcesses): |
94 multiprocessing.Process(target=worker, args=(taskQueue, doneQueue))\ |
94 multiprocessing.Process(target=worker, args=(taskQueue, doneQueue))\ |
95 .start() |
95 .start() |
96 |
96 |
97 # Get and send results |
97 # Get and send results |
98 endIndex = len(argumentsList) - initialTasks |
98 endIndex = len(argumentsList) - initialTasks |
118 |
118 |
119 if i < endIndex: |
119 if i < endIndex: |
120 taskQueue.put(argumentsList[i + initialTasks]) |
120 taskQueue.put(argumentsList[i + initialTasks]) |
121 |
121 |
122 # Tell child processes to stop |
122 # Tell child processes to stop |
123 for i in range(NumberOfProcesses): |
123 for _ in range(NumberOfProcesses): |
124 taskQueue.put('STOP') |
124 taskQueue.put('STOP') |
125 |
125 |
126 |
126 |
127 def worker(inputQueue, outputQueue): |
127 def worker(inputQueue, outputQueue): |
128 """ |
128 """ |