Plugins/CheckerPlugins/Tabnanny/Tabnanny.py

changeset 5672
495b53f37f6c
parent 5597
3d88d53f8c2b
child 5683
66b11f5171e8
diff -r 47cc72334684 -r 495b53f37f6c Plugins/CheckerPlugins/Tabnanny/Tabnanny.py
--- a/Plugins/CheckerPlugins/Tabnanny/Tabnanny.py	Fri Mar 31 17:28:12 2017 +0200
+++ b/Plugins/CheckerPlugins/Tabnanny/Tabnanny.py	Fri Mar 31 17:29:55 2017 +0200
@@ -49,6 +49,7 @@
 except (ImportError):
     import io    # __IGNORE_WARNING__
 import multiprocessing
+import queue
 
 if not hasattr(tokenize, 'NL'):
     raise ValueError("tokenize.NL doesn't exist -- tokenize module too old")
@@ -165,11 +166,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])
 

eric ide

mercurial