diff options
| author | Paul Morelle <pmo@odoo.com> | 2020-06-16 20:49:37 +0000 |
|---|---|---|
| committer | Paul Morelle <pmo@odoo.com> | 2020-06-17 08:49:29 +0000 |
| commit | 8a94f62e08f40af5dd67bcc59cab90d6b339012d (patch) | |
| tree | e4c5092eb1c8b03f6e8dff8d877649c075e85fbb | |
| parent | f5089a0b0e9e7d289d190475891e76dbe6ba6eca (diff) | |
[FIX] odoo: stop bloating sys.meta_path
Every call of initialize_sys_path was adding two new hooks to the
sys.meta_path, resulting in very long loading times on databases having
a lot of modules.
For example, 2.27s instead of 752 on a database having 130 installed
modules.
References:
- odoo/odoo#45780
- odoo/odoo#45662
closes odoo/odoo#53121
X-original-commit: 2444fde7f852787d87589a93c4bc385d76ff20e9
Signed-off-by: Christophe Simonis <chs@odoo.com>
Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
| -rw-r--r-- | odoo/modules/module.py | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/odoo/modules/module.py b/odoo/modules/module.py index f545a720109..61117965b0f 100644 --- a/odoo/modules/module.py +++ b/odoo/modules/module.py @@ -102,10 +102,6 @@ def initialize_sys_path(): Setup the addons path ``odoo.addons.__path__`` with various defaults and explicit directories. """ - # if getattr(initialize_sys_path, 'called', False): # only initialize once - # return - initialize_sys_path.called = True - # hook odoo.addons on data dir dd = os.path.normcase(tools.config.addons_data_dir) if os.access(dd, os.R_OK) and dd not in odoo.addons.__path__: @@ -138,9 +134,10 @@ def initialize_sys_path(): sys.modules["odoo.addons.base.maintenance.migrations"] = upgrade # hook deprecated module alias from openerp to odoo and "crm"-like to odoo.addons - if getattr(initialize_sys_path, 'called', False): # only initialize once + if not getattr(initialize_sys_path, 'called', False): # only initialize once sys.meta_path.insert(0, OdooHook()) sys.meta_path.insert(0, AddonsHook()) + initialize_sys_path.called = True def get_module_path(module, downloaded=False, display_warning=True): |
