[IMP] cron: no master cron thread when no workers are needed.
authorVo Minh Thu <vmt@openerp.com>
Mon, 13 Feb 2012 11:53:54 +0000 (12:53 +0100)
committerVo Minh Thu <vmt@openerp.com>
Mon, 13 Feb 2012 11:53:54 +0000 (12:53 +0100)
bzr revid: vmt@openerp.com-20120213115354-qa4kqx6hea82q8se

openerp/cron.py
openerp/modules/registry.py
openerp/service/__init__.py

index 7b67877..8551ed7 100644 (file)
@@ -204,9 +204,12 @@ def start_master_thread():
         _logger.warning("Connection pool size (%s) is set lower than max number of cron threads (%s), "
                         "this may cause trouble if you reach that number of parallel cron tasks.",
                         db_maxconn, _thread_slots)
-    t = threading.Thread(target=runner, name="openerp.cron.master_thread")
-    t.setDaemon(True)
-    t.start()
-    _logger.debug("Master cron daemon started!")
+    if _thread_slots:
+        t = threading.Thread(target=runner, name="openerp.cron.master_thread")
+        t.setDaemon(True)
+        t.start()
+        _logger.debug("Master cron daemon started!")
+    else:
+        _logger.info("No master cron daemon (0 workers needed).")
 
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
index 9053eb8..bc04d45 100644 (file)
@@ -286,7 +286,6 @@ class RegistryManager(object):
                 cr = registry.db.cursor()
                 r = 1
                 try:
-                    pass
                     cr.execute("select nextval('base_cache_signaling')")
                     r = cr.fetchone()[0]
                 finally:
index bc9a83b..c387d27 100644 (file)
@@ -65,7 +65,7 @@ def start_services():
     netrpc_server.init_servers()
 
     # Start the main cron thread.
-    #openerp.cron.start_master_thread()
+    openerp.cron.start_master_thread()
 
     # Start the top-level servers threads (normally HTTP, HTTPS, and NETRPC).
     openerp.netsvc.Server.startAll()