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:29:36 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 27 Sep 2021 15:29:36 +0200
branch
eric7
changeset 8650
100726f55a9a
parent 8649
01eb78cba360
child 8651
ce4c3c401482

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

eric7/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleChecker.py file | annotate | diff | comparison | revisions
eric7/Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheck.py file | annotate | diff | comparison | revisions
eric7/Plugins/CheckerPlugins/SyntaxChecker/jsCheckSyntax.py file | annotate | diff | comparison | revisions
eric7/Plugins/CheckerPlugins/SyntaxChecker/jsonCheckSyntax.py file | annotate | diff | comparison | revisions
eric7/Plugins/CheckerPlugins/SyntaxChecker/tomlCheckSyntax.py file | annotate | diff | comparison | revisions
eric7/Plugins/CheckerPlugins/SyntaxChecker/yamlCheckSyntax.py file | annotate | diff | comparison | revisions
--- a/eric7/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleChecker.py	Mon Sep 27 11:51:38 2021 +0200
+++ b/eric7/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleChecker.py	Mon Sep 27 15:29:36 2021 +0200
@@ -225,10 +225,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
@@ -258,9 +261,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 style check.
     
--- a/eric7/Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheck.py	Mon Sep 27 11:51:38 2021 +0200
+++ b/eric7/Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheck.py	Mon Sep 27 15:29:36 2021 +0200
@@ -150,10 +150,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
@@ -183,9 +186,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 syntax check.
     
--- a/eric7/Plugins/CheckerPlugins/SyntaxChecker/jsCheckSyntax.py	Mon Sep 27 11:51:38 2021 +0200
+++ b/eric7/Plugins/CheckerPlugins/SyntaxChecker/jsCheckSyntax.py	Mon Sep 27 15:29:36 2021 +0200
@@ -100,10 +100,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
@@ -133,9 +136,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 syntax check.
     
--- a/eric7/Plugins/CheckerPlugins/SyntaxChecker/jsonCheckSyntax.py	Mon Sep 27 11:51:38 2021 +0200
+++ b/eric7/Plugins/CheckerPlugins/SyntaxChecker/jsonCheckSyntax.py	Mon Sep 27 15:29:36 2021 +0200
@@ -101,10 +101,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
@@ -134,9 +137,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 syntax check.
     
--- a/eric7/Plugins/CheckerPlugins/SyntaxChecker/tomlCheckSyntax.py	Mon Sep 27 11:51:38 2021 +0200
+++ b/eric7/Plugins/CheckerPlugins/SyntaxChecker/tomlCheckSyntax.py	Mon Sep 27 15:29:36 2021 +0200
@@ -101,10 +101,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
@@ -134,9 +137,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 syntax check.
     
--- a/eric7/Plugins/CheckerPlugins/SyntaxChecker/yamlCheckSyntax.py	Mon Sep 27 11:51:38 2021 +0200
+++ b/eric7/Plugins/CheckerPlugins/SyntaxChecker/yamlCheckSyntax.py	Mon Sep 27 15:29:36 2021 +0200
@@ -101,10 +101,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
@@ -134,9 +137,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 syntax check.
     

eric ide

mercurial