106 .start() |
107 .start() |
107 |
108 |
108 # Get and send results |
109 # Get and send results |
109 endIndex = len(argumentsList) - initialTasks |
110 endIndex = len(argumentsList) - initialTasks |
110 for i in range(len(argumentsList)): |
111 for i in range(len(argumentsList)): |
111 filename, result = doneQueue.get() |
112 resultSent = False |
112 send(fx, filename, result) |
113 wasCancelled = False |
113 if cancelled(): |
114 |
|
115 while not resultSent: |
|
116 try: |
|
117 # get result (waiting max. 3 seconds and send it to frontend |
|
118 filename, result = doneQueue.get() |
|
119 send(fx, filename, result) |
|
120 resultSent = True |
|
121 except queue.Empty: |
|
122 # ignore empty queue, just carry on |
|
123 if cancelled(): |
|
124 wasCancelled = True |
|
125 break |
|
126 |
|
127 if wasCancelled or cancelled(): |
114 # just exit the loop ignoring the results of queued tasks |
128 # just exit the loop ignoring the results of queued tasks |
115 break |
129 break |
|
130 |
116 if i < endIndex: |
131 if i < endIndex: |
117 taskQueue.put(argumentsList[i + initialTasks]) |
132 taskQueue.put(argumentsList[i + initialTasks]) |
118 |
133 |
119 # Tell child processes to stop |
134 # Tell child processes to stop |
120 for i in range(NumberOfProcesses): |
135 for i in range(NumberOfProcesses): |
121 taskQueue.put('STOP') |
136 taskQueue.put('STOP') |
122 |
137 |
123 |
138 |
124 def worker(input, output): |
139 def worker(inputQueue, outputQueue): |
125 """ |
140 """ |
126 Module function acting as the parallel worker for the style check. |
141 Module function acting as the parallel worker for the style check. |
127 |
142 |
128 @param input input queue (multiprocessing.Queue) |
143 @param inputQueue input queue (multiprocessing.Queue) |
129 @param output output queue (multiprocessing.Queue) |
144 @param outputQueue output queue (multiprocessing.Queue) |
130 """ |
145 """ |
131 for filename, args in iter(input.get, 'STOP'): |
146 for filename, args in iter(inputQueue.get, 'STOP'): |
132 source = args[0] |
147 source = args[0] |
133 result = __jsSyntaxCheck(filename, source) |
148 result = __jsSyntaxCheck(filename, source) |
134 output.put((filename, result)) |
149 outputQueue.put((filename, result)) |
135 |
150 |
136 |
151 |
137 def __jsSyntaxCheck(file, codestring): |
152 def __jsSyntaxCheck(file, codestring): |
138 """ |
153 """ |
139 Function to check a Javascript source file for syntax errors. |
154 Function to check a Javascript source file for syntax errors. |