From 9c769c9a990064012409747596d8298cd477c31a Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Fri, 11 Oct 2013 11:26:32 +0200 Subject: [PATCH] [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 lp bug: https://launchpad.net/bugs/1238560 fixed bzr revid: guewen.baconnier@camptocamp.com-20131011092632-b267vhdadh7q9som --- openerp/modules/registry.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/openerp/modules/registry.py b/openerp/modules/registry.py index 14b5dd917b1..19a957ead59 100644 --- a/openerp/modules/registry.py +++ b/openerp/modules/registry.py @@ -185,15 +185,16 @@ class RegistryManager(object): @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,