80 initialTasks = 2 * NumberOfProcesses |
80 initialTasks = 2 * NumberOfProcesses |
81 for task in argumentsList[:initialTasks]: |
81 for task in argumentsList[:initialTasks]: |
82 taskQueue.put(task) |
82 taskQueue.put(task) |
83 |
83 |
84 # Start worker processes |
84 # Start worker processes |
85 for _ in range(NumberOfProcesses): |
85 workers = [ |
86 multiprocessing.Process( |
86 multiprocessing.Process( |
87 target=worker, args=(taskQueue, doneQueue)).start() |
87 target=workerTask, args=(taskQueue, doneQueue) |
|
88 ) for _ in range(NumberOfProcesses) |
|
89 ] |
|
90 for worker in workers: |
|
91 worker.start() |
88 |
92 |
89 # Get and send results |
93 # Get and send results |
90 endIndex = len(argumentsList) - initialTasks |
94 endIndex = len(argumentsList) - initialTasks |
91 for i in range(len(argumentsList)): |
95 for i in range(len(argumentsList)): |
92 resultSent = False |
96 resultSent = False |
112 taskQueue.put(argumentsList[i + initialTasks]) |
116 taskQueue.put(argumentsList[i + initialTasks]) |
113 |
117 |
114 # Tell child processes to stop |
118 # Tell child processes to stop |
115 for _ in range(NumberOfProcesses): |
119 for _ in range(NumberOfProcesses): |
116 taskQueue.put('STOP') |
120 taskQueue.put('STOP') |
117 |
121 |
118 |
122 for worker in workers: |
119 def worker(inputQueue, outputQueue): |
123 worker.join() |
|
124 worker.close() |
|
125 |
|
126 |
|
127 def workerTask(inputQueue, outputQueue): |
120 """ |
128 """ |
121 Module function acting as the parallel worker for the cyclomatic |
129 Module function acting as the parallel worker for the cyclomatic |
122 complexity calculation. |
130 complexity calculation. |
123 |
131 |
124 @param inputQueue input queue |
132 @param inputQueue input queue |