RadonMetrics/CyclomaticComplexityCalculator.py

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

eric ide

mercurial