summaryrefslogtreecommitdiff
path: root/odoo/modules/registry.py
diff options
context:
space:
mode:
authorXavier Morel <xmo@odoo.com>2020-04-06 09:39:47 +0000
committerXavier Morel <xmo@odoo.com>2020-04-06 09:45:29 +0000
commit9d37cecfca8e6b8d4c0e2880f422673c526a3aef (patch)
treef1da785820ca7b0f3ab5124aff9212dac7267320 /odoo/modules/registry.py
parenteacc9bfe2579bf833a4620e4d1030fa075e18d32 (diff)
[FIX] core: iterations on LRU
Iteration methods on LRU were removed because they were not thread-safe and it's not clear that making them thread-safe is the correct thing to do, so not providing them seems saner. I thought I'd looked for usages of the LRU but apparently didn't look hard enough as I missed that it's used by the cron workers (apparently using the threaded server we only run crons for dbs currently living in the registry cache, the more you know). Convert these to iterating on the LRU's internal mapping, and also don't iterate on the LRU to clear its entries one by one when we can just clear the entire thing safely, although Registry.delete_all really seems completely unused. closes odoo/odoo#49023 Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
Diffstat (limited to 'odoo/modules/registry.py')
-rw-r--r--odoo/modules/registry.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/odoo/modules/registry.py b/odoo/modules/registry.py
index 02d1cd6e94a..9294cbbefdf 100644
--- a/odoo/modules/registry.py
+++ b/odoo/modules/registry.py
@@ -151,14 +151,13 @@ class Registry(Mapping):
""" Delete the registry linked to a given database. """
with cls._lock:
if db_name in cls.registries:
- cls.registries.pop(db_name)
+ del cls.registries[db_name]
@classmethod
def delete_all(cls):
""" Delete all the registries. """
with cls._lock:
- for db_name in list(cls.registries.keys()):
- cls.delete(db_name)
+ cls.registries.clear()
#
# Mapping abstract methods implementation