Changed the 'multiprocessing.Process()' code of the background batch services to (hopefully) cure the slow down when used multiple times. eric7

Mon, 27 Sep 2021 15:43:50 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 27 Sep 2021 15:43:50 +0200
branch
eric7
changeset 87
6ae91562f0a7
parent 86
326e08294b3d
child 88
8b61e17a6d63

Changed the 'multiprocessing.Process()' code of the background batch services to (hopefully) cure the slow down when used multiple times.

.hgignore file | annotate | diff | comparison | revisions
ChangeLog file | annotate | diff | comparison | revisions
PluginMetricsRadon.py file | annotate | diff | comparison | revisions
RadonMetrics/CodeMetricsCalculator.py file | annotate | diff | comparison | revisions
RadonMetrics/CyclomaticComplexityCalculator.py file | annotate | diff | comparison | revisions
RadonMetrics/Documentation/source/Plugin_Metrics_Radon.PluginMetricsRadon.html file | annotate | diff | comparison | revisions
RadonMetrics/Documentation/source/Plugin_Metrics_Radon.RadonMetrics.CodeMetricsCalculator.html file | annotate | diff | comparison | revisions
RadonMetrics/Documentation/source/Plugin_Metrics_Radon.RadonMetrics.CyclomaticComplexityCalculator.html file | annotate | diff | comparison | revisions
RadonMetrics/Documentation/source/Plugin_Metrics_Radon.RadonMetrics.CyclomaticComplexityDialog.html file | annotate | diff | comparison | revisions
RadonMetrics/Documentation/source/Plugin_Metrics_Radon.RadonMetrics.MaintainabilityIndexCalculator.html file | annotate | diff | comparison | revisions
RadonMetrics/Documentation/source/Plugin_Metrics_Radon.RadonMetrics.MaintainabilityIndexDialog.html file | annotate | diff | comparison | revisions
RadonMetrics/Documentation/source/Plugin_Metrics_Radon.RadonMetrics.RawMetricsDialog.html file | annotate | diff | comparison | revisions
RadonMetrics/Documentation/source/index-Plugin_Metrics_Radon.RadonMetrics.html file | annotate | diff | comparison | revisions
RadonMetrics/Documentation/source/index-Plugin_Metrics_Radon.html file | annotate | diff | comparison | revisions
RadonMetrics/Documentation/source/index.html file | annotate | diff | comparison | revisions
RadonMetrics/Documentation/source/styles.css file | annotate | diff | comparison | revisions
RadonMetrics/MaintainabilityIndexCalculator.py file | annotate | diff | comparison | revisions
--- a/.hgignore	Sun Jul 11 14:40:09 2021 +0200
+++ b/.hgignore	Mon Sep 27 15:43:50 2021 +0200
@@ -2,6 +2,7 @@
 glob:.eric7project
 glob:.ropeproject
 glob:.directory
+glob:.jedi
 glob:**.pyc
 glob:**.pyo
 glob:**.orig
--- a/ChangeLog	Sun Jul 11 14:40:09 2021 +0200
+++ b/ChangeLog	Mon Sep 27 15:43:50 2021 +0200
@@ -1,5 +1,8 @@
 ChangeLog
 ---------
+Version 1.0.2:
+- bug fixes
+
 Version 1.0.1:
 - bug fixes
 
--- a/PluginMetricsRadon.py	Sun Jul 11 14:40:09 2021 +0200
+++ b/PluginMetricsRadon.py	Mon Sep 27 15:43:50 2021 +0200
@@ -28,7 +28,7 @@
 author = "Detlev Offenbach <detlev@die-offenbachs.de>"
 autoactivate = True
 deactivateable = True
-version = "1.0.1"
+version = "1.0.2"
 className = "RadonMetricsPlugin"
 packageName = "RadonMetrics"
 shortDescription = "Code metrics plugin using radon package"
--- a/RadonMetrics/CodeMetricsCalculator.py	Sun Jul 11 14:40:09 2021 +0200
+++ b/RadonMetrics/CodeMetricsCalculator.py	Mon Sep 27 15:43:50 2021 +0200
@@ -79,9 +79,13 @@
         taskQueue.put(task)
 
     # Start worker processes
-    for _ in range(NumberOfProcesses):
+    workers = [
         multiprocessing.Process(
-            target=worker, args=(taskQueue, doneQueue)).start()
+            target=workerTask, args=(taskQueue, doneQueue)
+        ) for _ in range(NumberOfProcesses)
+    ]
+    for worker in workers:
+        worker.start()
 
     # Get and send results
     endIndex = len(argumentsList) - initialTasks
@@ -111,9 +115,13 @@
     # Tell child processes to stop
     for _ in range(NumberOfProcesses):
         taskQueue.put('STOP')
+    
+    for worker in workers:
+        worker.join()
+        worker.close()
 
 
-def worker(inputQueue, outputQueue):
+def workerTask(inputQueue, outputQueue):
     """
     Module function acting as the parallel worker for the raw code metrics
     calculation.
--- a/RadonMetrics/CyclomaticComplexityCalculator.py	Sun Jul 11 14:40:09 2021 +0200
+++ b/RadonMetrics/CyclomaticComplexityCalculator.py	Mon Sep 27 15:43:50 2021 +0200
@@ -82,9 +82,13 @@
         taskQueue.put(task)
 
     # Start worker processes
-    for _ in range(NumberOfProcesses):
+    workers = [
         multiprocessing.Process(
-            target=worker, args=(taskQueue, doneQueue)).start()
+            target=workerTask, args=(taskQueue, doneQueue)
+        ) for _ in range(NumberOfProcesses)
+    ]
+    for worker in workers:
+        worker.start()
 
     # Get and send results
     endIndex = len(argumentsList) - initialTasks
@@ -114,9 +118,13 @@
     # Tell child processes to stop
     for _ in range(NumberOfProcesses):
         taskQueue.put('STOP')
+    
+    for worker in workers:
+        worker.join()
+        worker.close()
 
 
-def worker(inputQueue, outputQueue):
+def workerTask(inputQueue, outputQueue):
     """
     Module function acting as the parallel worker for the cyclomatic
     complexity calculation.
--- a/RadonMetrics/Documentation/source/Plugin_Metrics_Radon.PluginMetricsRadon.html	Sun Jul 11 14:40:09 2021 +0200
+++ b/RadonMetrics/Documentation/source/Plugin_Metrics_Radon.PluginMetricsRadon.html	Mon Sep 27 15:43:50 2021 +0200
@@ -2,21 +2,7 @@
 <html><head>
 <title>Plugin_Metrics_Radon.PluginMetricsRadon</title>
 <meta charset="UTF-8">
-<style>
-body {
-    background: #EDECE6;
-    margin: 0em 1em 10em 1em;
-    color: black;
-}
-
-h1 { color: white; background: #85774A; }
-h2 { color: white; background: #85774A; }
-h3 { color: white; background: #9D936E; }
-h4 { color: white; background: #9D936E; }
-    
-a { color: #BA6D36; }
-
-</style>
+<link rel="stylesheet" href="styles.css">
 </head>
 <body>
 <a NAME="top" ID="top"></a>
--- a/RadonMetrics/Documentation/source/Plugin_Metrics_Radon.RadonMetrics.CodeMetricsCalculator.html	Sun Jul 11 14:40:09 2021 +0200
+++ b/RadonMetrics/Documentation/source/Plugin_Metrics_Radon.RadonMetrics.CodeMetricsCalculator.html	Mon Sep 27 15:43:50 2021 +0200
@@ -2,21 +2,7 @@
 <html><head>
 <title>Plugin_Metrics_Radon.RadonMetrics.CodeMetricsCalculator</title>
 <meta charset="UTF-8">
-<style>
-body {
-    background: #EDECE6;
-    margin: 0em 1em 10em 1em;
-    color: black;
-}
-
-h1 { color: white; background: #85774A; }
-h2 { color: white; background: #85774A; }
-h3 { color: white; background: #9D936E; }
-h4 { color: white; background: #9D936E; }
-    
-a { color: #BA6D36; }
-
-</style>
+<link rel="stylesheet" href="styles.css">
 </head>
 <body>
 <a NAME="top" ID="top"></a>
@@ -64,7 +50,7 @@
 <td>Private function to calculate the raw code metrics of one file.</td>
 </tr>
 <tr>
-<td><a href="#worker">worker</a></td>
+<td><a href="#workerTask">workerTask</a></td>
 <td>Module function acting as the parallel worker for the raw code metrics calculation.</td>
 </tr>
 </table>
@@ -231,9 +217,9 @@
 <div align="right"><a href="#top">Up</a></div>
 <hr />
 <hr />
-<a NAME="worker" ID="worker"></a>
-<h2>worker</h2>
-<b>worker</b>(<i>inputQueue, outputQueue</i>)
+<a NAME="workerTask" ID="workerTask"></a>
+<h2>workerTask</h2>
+<b>workerTask</b>(<i>inputQueue, outputQueue</i>)
 
 <p>
     Module function acting as the parallel worker for the raw code metrics
--- a/RadonMetrics/Documentation/source/Plugin_Metrics_Radon.RadonMetrics.CyclomaticComplexityCalculator.html	Sun Jul 11 14:40:09 2021 +0200
+++ b/RadonMetrics/Documentation/source/Plugin_Metrics_Radon.RadonMetrics.CyclomaticComplexityCalculator.html	Mon Sep 27 15:43:50 2021 +0200
@@ -2,21 +2,7 @@
 <html><head>
 <title>Plugin_Metrics_Radon.RadonMetrics.CyclomaticComplexityCalculator</title>
 <meta charset="UTF-8">
-<style>
-body {
-    background: #EDECE6;
-    margin: 0em 1em 10em 1em;
-    color: black;
-}
-
-h1 { color: white; background: #85774A; }
-h2 { color: white; background: #85774A; }
-h3 { color: white; background: #9D936E; }
-h4 { color: white; background: #9D936E; }
-    
-a { color: #BA6D36; }
-
-</style>
+<link rel="stylesheet" href="styles.css">
 </head>
 <body>
 <a NAME="top" ID="top"></a>
@@ -68,7 +54,7 @@
 <td>Initialize the service and return the entry point.</td>
 </tr>
 <tr>
-<td><a href="#worker">worker</a></td>
+<td><a href="#workerTask">workerTask</a></td>
 <td>Module function acting as the parallel worker for the cyclomatic complexity calculation.</td>
 </tr>
 </table>
@@ -267,9 +253,9 @@
 <div align="right"><a href="#top">Up</a></div>
 <hr />
 <hr />
-<a NAME="worker" ID="worker"></a>
-<h2>worker</h2>
-<b>worker</b>(<i>inputQueue, outputQueue</i>)
+<a NAME="workerTask" ID="workerTask"></a>
+<h2>workerTask</h2>
+<b>workerTask</b>(<i>inputQueue, outputQueue</i>)
 
 <p>
     Module function acting as the parallel worker for the cyclomatic
--- a/RadonMetrics/Documentation/source/Plugin_Metrics_Radon.RadonMetrics.CyclomaticComplexityDialog.html	Sun Jul 11 14:40:09 2021 +0200
+++ b/RadonMetrics/Documentation/source/Plugin_Metrics_Radon.RadonMetrics.CyclomaticComplexityDialog.html	Mon Sep 27 15:43:50 2021 +0200
@@ -2,21 +2,7 @@
 <html><head>
 <title>Plugin_Metrics_Radon.RadonMetrics.CyclomaticComplexityDialog</title>
 <meta charset="UTF-8">
-<style>
-body {
-    background: #EDECE6;
-    margin: 0em 1em 10em 1em;
-    color: black;
-}
-
-h1 { color: white; background: #85774A; }
-h2 { color: white; background: #85774A; }
-h3 { color: white; background: #9D936E; }
-h4 { color: white; background: #9D936E; }
-    
-a { color: #BA6D36; }
-
-</style>
+<link rel="stylesheet" href="styles.css">
 </head>
 <body>
 <a NAME="top" ID="top"></a>
--- a/RadonMetrics/Documentation/source/Plugin_Metrics_Radon.RadonMetrics.MaintainabilityIndexCalculator.html	Sun Jul 11 14:40:09 2021 +0200
+++ b/RadonMetrics/Documentation/source/Plugin_Metrics_Radon.RadonMetrics.MaintainabilityIndexCalculator.html	Mon Sep 27 15:43:50 2021 +0200
@@ -2,21 +2,7 @@
 <html><head>
 <title>Plugin_Metrics_Radon.RadonMetrics.MaintainabilityIndexCalculator</title>
 <meta charset="UTF-8">
-<style>
-body {
-    background: #EDECE6;
-    margin: 0em 1em 10em 1em;
-    color: black;
-}
-
-h1 { color: white; background: #85774A; }
-h2 { color: white; background: #85774A; }
-h3 { color: white; background: #9D936E; }
-h4 { color: white; background: #9D936E; }
-    
-a { color: #BA6D36; }
-
-</style>
+<link rel="stylesheet" href="styles.css">
 </head>
 <body>
 <a NAME="top" ID="top"></a>
@@ -60,7 +46,7 @@
 <td>Private function to calculate the maintainability index of one file.</td>
 </tr>
 <tr>
-<td><a href="#worker">worker</a></td>
+<td><a href="#workerTask">workerTask</a></td>
 <td>Module function acting as the parallel worker for the maintainability index calculation.</td>
 </tr>
 </table>
@@ -200,9 +186,9 @@
 <div align="right"><a href="#top">Up</a></div>
 <hr />
 <hr />
-<a NAME="worker" ID="worker"></a>
-<h2>worker</h2>
-<b>worker</b>(<i>inputQueue, outputQueue</i>)
+<a NAME="workerTask" ID="workerTask"></a>
+<h2>workerTask</h2>
+<b>workerTask</b>(<i>inputQueue, outputQueue</i>)
 
 <p>
     Module function acting as the parallel worker for the maintainability
--- a/RadonMetrics/Documentation/source/Plugin_Metrics_Radon.RadonMetrics.MaintainabilityIndexDialog.html	Sun Jul 11 14:40:09 2021 +0200
+++ b/RadonMetrics/Documentation/source/Plugin_Metrics_Radon.RadonMetrics.MaintainabilityIndexDialog.html	Mon Sep 27 15:43:50 2021 +0200
@@ -2,21 +2,7 @@
 <html><head>
 <title>Plugin_Metrics_Radon.RadonMetrics.MaintainabilityIndexDialog</title>
 <meta charset="UTF-8">
-<style>
-body {
-    background: #EDECE6;
-    margin: 0em 1em 10em 1em;
-    color: black;
-}
-
-h1 { color: white; background: #85774A; }
-h2 { color: white; background: #85774A; }
-h3 { color: white; background: #9D936E; }
-h4 { color: white; background: #9D936E; }
-    
-a { color: #BA6D36; }
-
-</style>
+<link rel="stylesheet" href="styles.css">
 </head>
 <body>
 <a NAME="top" ID="top"></a>
--- a/RadonMetrics/Documentation/source/Plugin_Metrics_Radon.RadonMetrics.RawMetricsDialog.html	Sun Jul 11 14:40:09 2021 +0200
+++ b/RadonMetrics/Documentation/source/Plugin_Metrics_Radon.RadonMetrics.RawMetricsDialog.html	Mon Sep 27 15:43:50 2021 +0200
@@ -2,21 +2,7 @@
 <html><head>
 <title>Plugin_Metrics_Radon.RadonMetrics.RawMetricsDialog</title>
 <meta charset="UTF-8">
-<style>
-body {
-    background: #EDECE6;
-    margin: 0em 1em 10em 1em;
-    color: black;
-}
-
-h1 { color: white; background: #85774A; }
-h2 { color: white; background: #85774A; }
-h3 { color: white; background: #9D936E; }
-h4 { color: white; background: #9D936E; }
-    
-a { color: #BA6D36; }
-
-</style>
+<link rel="stylesheet" href="styles.css">
 </head>
 <body>
 <a NAME="top" ID="top"></a>
--- a/RadonMetrics/Documentation/source/index-Plugin_Metrics_Radon.RadonMetrics.html	Sun Jul 11 14:40:09 2021 +0200
+++ b/RadonMetrics/Documentation/source/index-Plugin_Metrics_Radon.RadonMetrics.html	Mon Sep 27 15:43:50 2021 +0200
@@ -2,21 +2,7 @@
 <html><head>
 <title>Plugin_Metrics_Radon.RadonMetrics</title>
 <meta charset="UTF-8">
-<style>
-body {
-    background: #EDECE6;
-    margin: 0em 1em 10em 1em;
-    color: black;
-}
-
-h1 { color: white; background: #85774A; }
-h2 { color: white; background: #85774A; }
-h3 { color: white; background: #9D936E; }
-h4 { color: white; background: #9D936E; }
-    
-a { color: #BA6D36; }
-
-</style>
+<link rel="stylesheet" href="styles.css">
 </head>
 <body>
 <h1>Plugin_Metrics_Radon.RadonMetrics</h1>
--- a/RadonMetrics/Documentation/source/index-Plugin_Metrics_Radon.html	Sun Jul 11 14:40:09 2021 +0200
+++ b/RadonMetrics/Documentation/source/index-Plugin_Metrics_Radon.html	Mon Sep 27 15:43:50 2021 +0200
@@ -2,21 +2,7 @@
 <html><head>
 <title>Plugin_Metrics_Radon</title>
 <meta charset="UTF-8">
-<style>
-body {
-    background: #EDECE6;
-    margin: 0em 1em 10em 1em;
-    color: black;
-}
-
-h1 { color: white; background: #85774A; }
-h2 { color: white; background: #85774A; }
-h3 { color: white; background: #9D936E; }
-h4 { color: white; background: #9D936E; }
-    
-a { color: #BA6D36; }
-
-</style>
+<link rel="stylesheet" href="styles.css">
 </head>
 <body>
 <h1>Plugin_Metrics_Radon</h1>
--- a/RadonMetrics/Documentation/source/index.html	Sun Jul 11 14:40:09 2021 +0200
+++ b/RadonMetrics/Documentation/source/index.html	Mon Sep 27 15:43:50 2021 +0200
@@ -2,21 +2,7 @@
 <html><head>
 <title>Table of contents</title>
 <meta charset="UTF-8">
-<style>
-body {
-    background: #EDECE6;
-    margin: 0em 1em 10em 1em;
-    color: black;
-}
-
-h1 { color: white; background: #85774A; }
-h2 { color: white; background: #85774A; }
-h3 { color: white; background: #9D936E; }
-h4 { color: white; background: #9D936E; }
-    
-a { color: #BA6D36; }
-
-</style>
+<link rel="stylesheet" href="styles.css">
 </head>
 <body>
 <h1>Table of contents</h1>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RadonMetrics/Documentation/source/styles.css	Mon Sep 27 15:43:50 2021 +0200
@@ -0,0 +1,12 @@
+body {
+    color: black;
+    background: #EDECE6;
+    margin: 0em 1em 10em 1em;
+}
+
+h1 { color: white; background: #85774A; }
+h2 { color: white; background: #85774A; }
+h3 { color: white; background: #9D936E; }
+h4 { color: white; background: #9D936E; }
+    
+a { color: #BA6D36; }
--- a/RadonMetrics/MaintainabilityIndexCalculator.py	Sun Jul 11 14:40:09 2021 +0200
+++ b/RadonMetrics/MaintainabilityIndexCalculator.py	Mon Sep 27 15:43:50 2021 +0200
@@ -82,9 +82,13 @@
         taskQueue.put(task)
 
     # Start worker processes
-    for _ in range(NumberOfProcesses):
+    workers = [
         multiprocessing.Process(
-            target=worker, args=(taskQueue, doneQueue)).start()
+            target=workerTask, args=(taskQueue, doneQueue)
+        ) for _ in range(NumberOfProcesses)
+    ]
+    for worker in workers:
+        worker.start()
 
     # Get and send results
     endIndex = len(argumentsList) - initialTasks
@@ -114,9 +118,13 @@
     # Tell child processes to stop
     for _ in range(NumberOfProcesses):
         taskQueue.put('STOP')
+    
+    for worker in workers:
+        worker.join()
+        worker.close()
 
 
-def worker(inputQueue, outputQueue):
+def workerTask(inputQueue, outputQueue):
     """
     Module function acting as the parallel worker for the maintainability
     index calculation.

eric ide

mercurial