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