From 7e8a1f7a0693c6b6af7b075b5bbae1f02a48c259 Mon Sep 17 00:00:00 2001 From: Jeremy Kersten Date: Fri, 17 Jul 2020 12:38:57 +0000 Subject: [PATCH] [FIX] tools: LRU doesn't have keys() method anymore Since commit 1b30a78b, LRU is now based on OrderedDict and keys can be found on dictionnary 'd' directly. closes odoo/odoo#55541 X-original-commit: 3f093da75765d66ed1e2d828e8b41ed05d936d0b Signed-off-by: Xavier Morel (xmo) --- odoo/tools/cache.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/odoo/tools/cache.py b/odoo/tools/cache.py index dce88781824..0e244f63a4b 100644 --- a/odoo/tools/cache.py +++ b/odoo/tools/cache.py @@ -2,7 +2,7 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. # decorator makes wrappers that have the same API as their wrapped function -from collections import defaultdict +from collections import Counter, defaultdict from decorator import decorator from inspect import signature import logging @@ -207,10 +207,7 @@ def log_ormcache_stats(sig=None, frame=None): for dbname, reg in sorted(Registry.registries.d.items()): # set logger prefix to dbname me.dbname = dbname - entries = defaultdict(int) - # beware: we use .keys() on purpose here (reg.cache is not a real dict) - for key in reg.cache.keys(): - entries[key[:2]] += 1 + entries = Counter(k[:2] for k in reg.cache.d) # show entries sorted by model name, method name for key in sorted(entries, key=lambda key: (key[0], key[1].__name__)): model, method = key