Corrected an issue in various checker services that caused them to block, if an exception was thrown in a checker class. release-1.0.4

Fri, 31 Mar 2017 17:56:43 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 31 Mar 2017 17:56:43 +0200
changeset 45
0f2eabfd5834
parent 44
509744519228
child 46
df1b6370965a

Corrected an issue in various checker services that caused them to block, if an exception was thrown in a checker class.

ChangeLog file | annotate | diff | comparison | revisions
PluginMetricsRadon.py file | annotate | diff | comparison | revisions
PluginMetricsRadon.zip file | annotate | diff | comparison | revisions
RadonMetrics/CodeMetricsCalculator.py file | annotate | diff | comparison | revisions
RadonMetrics/CyclomaticComplexityCalculator.py file | annotate | diff | comparison | revisions
RadonMetrics/MaintainabilityIndexCalculator.py file | annotate | diff | comparison | revisions
--- a/ChangeLog	Mon Mar 27 18:34:44 2017 +0200
+++ b/ChangeLog	Fri Mar 31 17:56:43 2017 +0200
@@ -1,5 +1,8 @@
 ChangeLog
 ---------
+Version 1.0.4:
+- bug fixes
+
 Version 1.0.3:
 - bug fixes
 
--- a/PluginMetricsRadon.py	Mon Mar 27 18:34:44 2017 +0200
+++ b/PluginMetricsRadon.py	Fri Mar 31 17:56:43 2017 +0200
@@ -28,7 +28,7 @@
 author = "Detlev Offenbach <detlev@die-offenbachs.de>"
 autoactivate = True
 deactivateable = True
-version = "1.0.3"
+version = "1.0.4"
 className = "RadonMetricsPlugin"
 packageName = "RadonMetrics"
 shortDescription = "Code metrics plugin using radon package"
Binary file PluginMetricsRadon.zip has changed
--- a/RadonMetrics/CodeMetricsCalculator.py	Mon Mar 27 18:34:44 2017 +0200
+++ b/RadonMetrics/CodeMetricsCalculator.py	Fri Mar 31 17:56:43 2017 +0200
@@ -15,6 +15,7 @@
     pass
 
 import multiprocessing
+import queue
 
 
 def initService():
@@ -86,11 +87,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])
 
--- a/RadonMetrics/CyclomaticComplexityCalculator.py	Mon Mar 27 18:34:44 2017 +0200
+++ b/RadonMetrics/CyclomaticComplexityCalculator.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])
 
--- 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