RadonMetrics/MaintainabilityIndexCalculator.py

changeset 45
0f2eabfd5834
parent 43
53dbd4f4d6c2
child 47
fa1024e1dfc9
diff -r 509744519228 -r 0f2eabfd5834 RadonMetrics/MaintainabilityIndexCalculator.py
--- a/RadonMetrics/MaintainabilityIndexCalculator.py	Mon Mar 27 18:34:44 2017 +0200
+++ b/RadonMetrics/MaintainabilityIndexCalculator.py	Fri Mar 31 17:56:43 2017 +0200
@@ -14,8 +14,9 @@
 except NameError:
     pass
 
+import sys
 import multiprocessing
-import sys
+import queue
 
 
 def initService():
@@ -89,11 +90,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