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