[FIX] deadlock between crons scheduling and new registry initialization creation

bzr revid: xmo@openerp.com-20110930150026-m0h99fqk6qgne8i1
This commit is contained in:
Xavier Morel 2011-09-30 17:00:26 +02:00
parent d4d2b1b5b8
commit 6d70751dd7
1 changed files with 9 additions and 11 deletions

View File

@ -131,13 +131,11 @@ class RegistryManager(object):
def get(cls, db_name, force_demo=False, status=None, update_module=False, def get(cls, db_name, force_demo=False, status=None, update_module=False,
pooljobs=True): pooljobs=True):
""" Return a registry for a given database name.""" """ Return a registry for a given database name."""
with cls.registries_lock: try:
if db_name in cls.registries: return cls.registries[db_name]
registry = cls.registries[db_name] except KeyError:
else: return cls.new(db_name, force_demo, status,
registry = cls.new(db_name, force_demo, status, update_module, pooljobs)
update_module, pooljobs)
return registry
@classmethod @classmethod
def new(cls, db_name, force_demo=False, status=None, def new(cls, db_name, force_demo=False, status=None,
@ -172,10 +170,10 @@ class RegistryManager(object):
finally: finally:
cr.close() cr.close()
if pooljobs: if pooljobs:
registry.schedule_cron_jobs() registry.schedule_cron_jobs()
return registry return registry
@classmethod @classmethod
def delete(cls, db_name): def delete(cls, db_name):
@ -218,4 +216,4 @@ class RegistryManager(object):
cls.registries[db_name].clear_caches() cls.registries[db_name].clear_caches()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: