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