Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheck.py

changeset 5762
76ef5f340007
parent 5683
66b11f5171e8
child 6048
82ad8ec9548c
--- a/Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheck.py	Tue Jun 20 14:45:35 2017 +0200
+++ b/Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheck.py	Wed Jun 21 19:40:59 2017 +0200
@@ -118,23 +118,33 @@
                                     ignoreStarImportWarnings)
 
 
-def syntaxAndPyflakesBatchCheck(argumentsList, send, fx, cancelled):
+def syntaxAndPyflakesBatchCheck(argumentsList, send, fx, cancelled,
+                                maxProcesses=0):
     """
     Module function to check syntax for a batch of files.
     
     @param argumentsList list of arguments tuples as given for
         syntaxAndPyflakesCheck
-    @param send reference to send function (function)
-    @param fx registered service name (string)
+    @type list
+    @param send reference to send function
+    @type func
+    @param fx registered service name
+    @type str
     @param cancelled reference to function checking for a cancellation
-        (function)
+    @type func
+    @param maxProcesses number of processes to be used
+    @type int
     """
-    try:
-        NumberOfProcesses = multiprocessing.cpu_count()
-        if NumberOfProcesses >= 1:
-            NumberOfProcesses -= 1
-    except NotImplementedError:
-        NumberOfProcesses = 1
+    if maxProcesses == 0:
+        # determine based on CPU count
+        try:
+            NumberOfProcesses = multiprocessing.cpu_count()
+            if NumberOfProcesses >= 1:
+                NumberOfProcesses -= 1
+        except NotImplementedError:
+            NumberOfProcesses = 1
+    else:
+        NumberOfProcesses = maxProcesses
 
     # Create queues
     taskQueue = multiprocessing.Queue()

eric ide

mercurial