RadonMetrics/CodeMetricsCalculator.py

changeset 45
0f2eabfd5834
parent 43
53dbd4f4d6c2
child 47
fa1024e1dfc9
equal deleted inserted replaced
44:509744519228 45:0f2eabfd5834
13 str = unicode # __IGNORE_EXCEPTION__ __IGNORE_WARNING__ 13 str = unicode # __IGNORE_EXCEPTION__ __IGNORE_WARNING__
14 except NameError: 14 except NameError:
15 pass 15 pass
16 16
17 import multiprocessing 17 import multiprocessing
18 import queue
18 19
19 20
20 def initService(): 21 def initService():
21 """ 22 """
22 Initialize the service and return the entry point. 23 Initialize the service and return the entry point.
84 .start() 85 .start()
85 86
86 # Get and send results 87 # Get and send results
87 endIndex = len(argumentsList) - initialTasks 88 endIndex = len(argumentsList) - initialTasks
88 for i in range(len(argumentsList)): 89 for i in range(len(argumentsList)):
89 filename, result = doneQueue.get() 90 resultSent = False
90 send(fx, filename, result) 91 wasCancelled = False
91 if cancelled(): 92
93 while not resultSent:
94 try:
95 # get result (waiting max. 3 seconds and send it to frontend
96 filename, result = doneQueue.get()
97 send(fx, filename, result)
98 resultSent = True
99 except queue.Empty:
100 # ignore empty queue, just carry on
101 if cancelled():
102 wasCancelled = True
103 break
104
105 if wasCancelled or cancelled():
92 # just exit the loop ignoring the results of queued tasks 106 # just exit the loop ignoring the results of queued tasks
93 break 107 break
108
94 if i < endIndex: 109 if i < endIndex:
95 taskQueue.put(argumentsList[i + initialTasks]) 110 taskQueue.put(argumentsList[i + initialTasks])
96 111
97 # Tell child processes to stop 112 # Tell child processes to stop
98 for i in range(NumberOfProcesses): 113 for i in range(NumberOfProcesses):

eric ide

mercurial