161 initialTasks = 2 * NumberOfProcesses |
161 initialTasks = 2 * NumberOfProcesses |
162 for task in argumentsList[:initialTasks]: |
162 for task in argumentsList[:initialTasks]: |
163 taskQueue.put(task) |
163 taskQueue.put(task) |
164 |
164 |
165 # Start worker processes |
165 # Start worker processes |
166 for i in range(NumberOfProcesses): |
166 for _ in range(NumberOfProcesses): |
167 multiprocessing.Process(target=worker, args=(taskQueue, doneQueue))\ |
167 multiprocessing.Process(target=worker, args=(taskQueue, doneQueue))\ |
168 .start() |
168 .start() |
169 |
169 |
170 # Get and send results |
170 # Get and send results |
171 endIndex = len(argumentsList) - initialTasks |
171 endIndex = len(argumentsList) - initialTasks |
191 |
191 |
192 if i < endIndex: |
192 if i < endIndex: |
193 taskQueue.put(argumentsList[i + initialTasks]) |
193 taskQueue.put(argumentsList[i + initialTasks]) |
194 |
194 |
195 # Tell child processes to stop |
195 # Tell child processes to stop |
196 for i in range(NumberOfProcesses): |
196 for _ in range(NumberOfProcesses): |
197 taskQueue.put('STOP') |
197 taskQueue.put('STOP') |
198 |
198 |
199 |
199 |
200 def worker(inputQueue, outputQueue): |
200 def worker(inputQueue, outputQueue): |
201 """ |
201 """ |