Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleChecker.py

changeset 5672
495b53f37f6c
parent 5661
ae4f5cdc3d00
child 5683
66b11f5171e8
equal deleted inserted replaced
5671:47cc72334684 5672:495b53f37f6c
7 Module implementing the code style checker. 7 Module implementing the code style checker.
8 """ 8 """
9 9
10 import sys 10 import sys
11 import multiprocessing 11 import multiprocessing
12 import queue
12 13
13 import pycodestyle 14 import pycodestyle
14 from NamingStyleChecker import NamingStyleChecker 15 from NamingStyleChecker import NamingStyleChecker
15 16
16 # register the name checker 17 # register the name checker
17 pycodestyle.register_check(NamingStyleChecker, NamingStyleChecker.Codes) 18 pycodestyle.register_check(NamingStyleChecker, NamingStyleChecker.Codes)
18 19
19 from DocStyleChecker import DocStyleChecker 20 from DocStyleChecker import DocStyleChecker
20 from MiscellaneousChecker import MiscellaneousChecker 21 from MiscellaneousChecker import MiscellaneousChecker
21 # TODO: rename the following module
22 from ComplexityChecker import ComplexityChecker 22 from ComplexityChecker import ComplexityChecker
23 23
24 24
25 def initService(): 25 def initService():
26 """ 26 """
152 .start() 152 .start()
153 153
154 # Get and send results 154 # Get and send results
155 endIndex = len(argumentsList) - initialTasks 155 endIndex = len(argumentsList) - initialTasks
156 for i in range(len(argumentsList)): 156 for i in range(len(argumentsList)):
157 filename, result = doneQueue.get() 157 resultSent = False
158 send(fx, filename, result) 158 wasCancelled = False
159 if cancelled(): 159
160 while not resultSent:
161 try:
162 # get result (waiting max. 3 seconds and send it to frontend
163 filename, result = doneQueue.get(timeout=3)
164 send(fx, filename, result)
165 resultSent = True
166 except queue.Empty:
167 # ignore empty queue, just carry on
168 if cancelled():
169 wasCancelled = True
170 break
171
172 if wasCancelled or cancelled():
160 # just exit the loop ignoring the results of queued tasks 173 # just exit the loop ignoring the results of queued tasks
161 break 174 break
175
162 if i < endIndex: 176 if i < endIndex:
163 taskQueue.put(argumentsList[i + initialTasks]) 177 taskQueue.put(argumentsList[i + initialTasks])
164 178
165 # Tell child processes to stop 179 # Tell child processes to stop
166 for i in range(NumberOfProcesses): 180 for i in range(NumberOfProcesses):

eric ide

mercurial