From 5b3bf7254f7e08920eb7ea3d06c56f8d6a73f10c Mon Sep 17 00:00:00 2001 From: Nils Hamerlinck Date: Tue, 6 Jul 2021 13:58:44 +0000 Subject: [PATCH] [ADD] http: allow env variable to disable session_gc Introduce the env variable ODOO_DISABLE_SESSION_GC to disable session_gc on high-volume systems and avoid random slow calls as discussed in https://github.com/odoo/odoo/pull/70063 closes odoo/odoo#73376 X-original-commit: a61d459a200a56fba74f655f73b10d1ddd8e3a1e Signed-off-by: Olivier Dony (odo) --- odoo/http.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/odoo/http.py b/odoo/http.py index d9343819113..1013aba08a6 100644 --- a/odoo/http.py +++ b/odoo/http.py @@ -55,6 +55,7 @@ from .tools.func import lazy_property from .tools import profiler from .tools import ustr, consteq, frozendict, pycompat, unique, date_utils from .tools.mimetypes import guess_mimetype +from .tools.misc import str2bool from .tools._vendor import sessions from .modules.module import read_manifest @@ -1174,6 +1175,14 @@ def session_gc(session_store): except OSError: pass +ODOO_DISABLE_SESSION_GC = str2bool(os.environ.get('ODOO_DISABLE_SESSION_GC', '0')) + +if ODOO_DISABLE_SESSION_GC: + # empty function, in case another module would be + # calling it out of setup_session() + session_gc = lambda s: None + + #---------------------------------------------------------- # WSGI Layer #---------------------------------------------------------- @@ -1279,6 +1288,8 @@ class Root(object): # Setup http sessions path = odoo.tools.config.session_dir _logger.debug('HTTP sessions stored in: %s', path) + if ODOO_DISABLE_SESSION_GC: + _logger.info('Default session GC disabled, manual GC required.') return sessions.FilesystemSessionStore( path, session_class=OpenERPSession, renew_missing=True)