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