[Greater-commits] r3640 - trunk/GREAT-ER/Greater/Modules

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Jul 22 17:27:51 CEST 2011


Author: aheinecke
Date: 2011-07-22 17:27:51 +0200 (Fri, 22 Jul 2011)
New Revision: 3640

Modified:
   trunk/GREAT-ER/Greater/Modules/model.py
Log:
Quote paths in scheduler/worker calling and run multiple workers
The path quoting fixes the problem that greater was unable to be executed
from a path with a whitespace in it,..


Modified: trunk/GREAT-ER/Greater/Modules/model.py
===================================================================
--- trunk/GREAT-ER/Greater/Modules/model.py	2011-07-22 10:04:57 UTC (rev 3639)
+++ trunk/GREAT-ER/Greater/Modules/model.py	2011-07-22 15:27:51 UTC (rev 3640)
@@ -51,6 +51,7 @@
 import os
 import re
 import xmlrpclib
+from multiprocessing import cpu_count
 
 class SchedulerProcess:
 
@@ -88,13 +89,14 @@
         """
         python_exe = sys.executable
         path = os.path.join(GreaterModel.__path__[0], '..')
-        cmdline = [python_exe, os.path.join(path, 'start_scheduler.py'),
+        cmdline = ['"%s"' % python_exe,
+                   '"%s"' % os.path.join(path, 'start_scheduler.py'),
                    '--client-port', str(self.client_port),
                    '--worker-port', str(self.worker_port)]
         if self.port_scan_range is not None:
             cmdline.extend(["--port-scan-range", str(self.port_scan_range)])
         if self.log_file is not None:
-            cmdline.extend(['--log-file', self.log_file])
+            cmdline.extend(['--log-file', '"%s"' % self.log_file])
         if self.db_api_module is not None:
             cmdline.extend(['--db-api-module', self.db_api_module])
         if self.allow_shutdown:
@@ -240,10 +242,11 @@
         """Start the worker"""
         python_exe = sys.executable
         path = os.path.join(GreaterModel.__path__[0], '..')
-        cmdline = [python_exe, os.path.join(path, 'start_worker.py'),
+        cmdline = ['"%s"' % python_exe,
+                   '"%s"' % os.path.join(path, 'start_worker.py'),
                    '--port', str(self.scheduler_port)]
         if (self.log_file is not None):
-            cmdline.extend(['--log-file', self.log_file])
+            cmdline.extend(['--log-file', '"%s"' % self.log_file])
         if (self.db_api_module is not None):
             cmdline.extend(['--db-api-module', self.db_api_module])
 
@@ -335,10 +338,13 @@
                                           db_api_module = self.db_api_module,
                                           log_file = os.path.join(logdir, "scheduler.log"))
                 server.start()
-                worker = WorkerProcess(scheduler_port = server.real_worker_port,
-                                       db_api_module = self.db_api_module,
-                                       log_file = os.path.join(logdir, "worker%s.log" % "1"))
-                worker.start()
+                # Start multiple workers for the CPU's available
+                for i in range(0, cpu_count()):
+                    worker = WorkerProcess(scheduler_port = server.real_worker_port,
+                                           test_port = 10103 + i,
+                                           db_api_module = self.db_api_module,
+                                           log_file = os.path.join(logdir, "worker%s.log" % i))
+                    worker.start()
                 server.wait_for_worker()
                 self.rpc = xmlrpclib.Server('http://localhost:%d' % \
                                         server.real_client_port)



More information about the Greater-commits mailing list