← Back to team overview

openerp-community-reviewer team mailing list archive

lp:~camptocamp/ocb-server/7.0-registrymanager-rlock-1238560-gbr into lp:ocb-server

 

Guewen Baconnier @ Camptocamp has proposed merging lp:~camptocamp/ocb-server/7.0-registrymanager-rlock-1238560-gbr into lp:ocb-server.

Commit message:
[FIX]  missing a threading.RLock in RegistryManager.get():
  
if no registry exists and several calls to RegistryManager.get() are called at the same time
by several threads, several registries will be created one after the other and only the last
one will be kept in cls.registries

Requested reviews:
  OpenERP Community Backports Team (ocb)
Related bugs:
  Bug #1238560 in OpenERP Community Backports (Server): "RegistryManager: threading.RLock is missing"
  https://bugs.launchpad.net/ocb-server/+bug/1238560

For more details, see:
https://code.launchpad.net/~camptocamp/ocb-server/7.0-registrymanager-rlock-1238560-gbr/+merge/193749

Fixes lp:1238560

Details on the bug report.
-- 
https://code.launchpad.net/~camptocamp/ocb-server/7.0-registrymanager-rlock-1238560-gbr/+merge/193749
Your team OpenERP Community Backports Team is requested to review the proposed merge of lp:~camptocamp/ocb-server/7.0-registrymanager-rlock-1238560-gbr into lp:ocb-server.
=== modified file 'openerp/modules/registry.py'
--- openerp/modules/registry.py	2013-10-11 12:39:14 +0000
+++ openerp/modules/registry.py	2013-11-04 10:54:36 +0000
@@ -185,15 +185,16 @@
     @classmethod
     def get(cls, db_name, force_demo=False, status=None, update_module=False):
         """ Return a registry for a given database name."""
-        try:
-            return cls.registries[db_name]
-        except KeyError:
-            return cls.new(db_name, force_demo, status,
-                           update_module)
-        finally:
-            # set db tracker - cleaned up at the WSGI
-            # dispatching phase in openerp.service.wsgi_server.application
-            threading.current_thread().dbname = db_name
+        with cls.registries_lock:
+            try:
+                return cls.registries[db_name]
+            except KeyError:
+                return cls.new(db_name, force_demo, status,
+                               update_module)
+            finally:
+                # set db tracker - cleaned up at the WSGI
+                # dispatching phase in openerp.service.wsgi_server.application
+                threading.current_thread().dbname = db_name
 
     @classmethod
     def new(cls, db_name, force_demo=False, status=None,


Follow ups