RadonMetrics/MaintainabilityIndexCalculator.py

branch
eric7
changeset 87
6ae91562f0a7
parent 75
e7ed383ac6a7
child 90
1405e41edc0b
equal deleted inserted replaced
86:326e08294b3d 87:6ae91562f0a7
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')
121
122 for worker in workers:
123 worker.join()
124 worker.close()
117 125
118 126
119 def worker(inputQueue, outputQueue): 127 def workerTask(inputQueue, outputQueue):
120 """ 128 """
121 Module function acting as the parallel worker for the maintainability 129 Module function acting as the parallel worker for the maintainability
122 index calculation. 130 index calculation.
123 131
124 @param inputQueue input queue 132 @param inputQueue input queue

eric ide

mercurial