98 initialTasks = 2 * NumberOfProcesses |
98 initialTasks = 2 * NumberOfProcesses |
99 for task in argumentsList[:initialTasks]: |
99 for task in argumentsList[:initialTasks]: |
100 taskQueue.put(task) |
100 taskQueue.put(task) |
101 |
101 |
102 # Start worker processes |
102 # Start worker processes |
103 for _ in range(NumberOfProcesses): |
103 workers = [ |
104 multiprocessing.Process( |
104 multiprocessing.Process( |
105 target=worker, args=(taskQueue, doneQueue) |
105 target=workerTask, args=(taskQueue, doneQueue) |
106 ).start() |
106 ) for _ in range(NumberOfProcesses) |
|
107 ] |
|
108 for worker in workers: |
|
109 worker.start() |
107 |
110 |
108 # Get and send results |
111 # Get and send results |
109 endIndex = len(argumentsList) - initialTasks |
112 endIndex = len(argumentsList) - initialTasks |
110 for i in range(len(argumentsList)): |
113 for i in range(len(argumentsList)): |
111 resultSent = False |
114 resultSent = False |
131 taskQueue.put(argumentsList[i + initialTasks]) |
134 taskQueue.put(argumentsList[i + initialTasks]) |
132 |
135 |
133 # Tell child processes to stop |
136 # Tell child processes to stop |
134 for _ in range(NumberOfProcesses): |
137 for _ in range(NumberOfProcesses): |
135 taskQueue.put('STOP') |
138 taskQueue.put('STOP') |
|
139 |
|
140 for worker in workers: |
|
141 worker.join() |
|
142 worker.close() |
136 |
143 |
137 |
144 |
138 def worker(inputQueue, outputQueue): |
145 def workerTask(inputQueue, outputQueue): |
139 """ |
146 """ |
140 Module function acting as the parallel worker for the syntax check. |
147 Module function acting as the parallel worker for the syntax check. |
141 |
148 |
142 @param inputQueue input queue (multiprocessing.Queue) |
149 @param inputQueue input queue (multiprocessing.Queue) |
143 @param outputQueue output queue (multiprocessing.Queue) |
150 @param outputQueue output queue (multiprocessing.Queue) |