--- a/Plugins/CheckerPlugins/SyntaxChecker/jsCheckSyntax.py Thu Mar 23 18:58:56 2017 +0100 +++ b/Plugins/CheckerPlugins/SyntaxChecker/jsCheckSyntax.py Fri Apr 07 18:33:59 2017 +0200 @@ -13,6 +13,7 @@ import os import sys import multiprocessing +import queue def initService(): @@ -108,11 +109,25 @@ # Get and send results endIndex = len(argumentsList) - initialTasks for i in range(len(argumentsList)): - filename, result = doneQueue.get() - send(fx, filename, result) - if cancelled(): + resultSent = False + wasCancelled = False + + while not resultSent: + try: + # get result (waiting max. 3 seconds and send it to frontend + filename, result = doneQueue.get() + send(fx, filename, result) + resultSent = True + except queue.Empty: + # ignore empty queue, just carry on + if cancelled(): + wasCancelled = True + break + + if wasCancelled or cancelled(): # just exit the loop ignoring the results of queued tasks break + if i < endIndex: taskQueue.put(argumentsList[i + initialTasks]) @@ -121,17 +136,17 @@ taskQueue.put('STOP') -def worker(input, output): +def worker(inputQueue, outputQueue): """ Module function acting as the parallel worker for the style check. - @param input input queue (multiprocessing.Queue) - @param output output queue (multiprocessing.Queue) + @param inputQueue input queue (multiprocessing.Queue) + @param outputQueue output queue (multiprocessing.Queue) """ - for filename, args in iter(input.get, 'STOP'): + for filename, args in iter(inputQueue.get, 'STOP'): source = args[0] result = __jsSyntaxCheck(filename, source) - output.put((filename, result)) + outputQueue.put((filename, result)) def __jsSyntaxCheck(file, codestring):