[MERGE] merge
[odoo/odoo.git] / bin / pooler.py
index 60ea806..e0a0ff2 100644 (file)
@@ -1,22 +1,21 @@
-# -*- encoding: utf-8 -*-
+# -*- coding: utf-8 -*-
 ##############################################################################
-#
-#    OpenERP, Open Source Management Solution  
-#    Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
-#    $Id$
+#    
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
-#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.     
 #
 ##############################################################################
 
@@ -25,7 +24,7 @@ pool_dic = {}
 def get_db_and_pool(db_name, force_demo=False, status=None, update_module=False):
     if not status:
         status={}
+
     db = get_db_only(db_name)
 
     if db_name in pool_dic:
@@ -35,7 +34,13 @@ def get_db_and_pool(db_name, force_demo=False, status=None, update_module=False)
         import osv.osv
         pool = osv.osv.osv_pool()
         pool_dic[db_name] = pool
-        addons.load_modules(db, force_demo, status, update_module)
+        
+        try:
+            addons.load_modules(db, force_demo, status, update_module)
+        except Exception, e:
+            del pool_dic[db_name]
+            raise
+
         cr = db.cursor()
         try:
             pool.init_set(cr, False)
@@ -51,6 +56,7 @@ def get_db_and_pool(db_name, force_demo=False, status=None, update_module=False)
 
 def restart_pool(db_name, force_demo=False, status=None, update_module=False):
     if db_name in pool_dic:
+        pool_dic[db_name].get('ir.cron').cancel(db_name)
         del pool_dic[db_name]
     return get_db_and_pool(db_name, force_demo, status, update_module=update_module)
 
@@ -75,4 +81,3 @@ def get_pool(db_name, force_demo=False, status=None, update_module=False):
     return pool
 
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-