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