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)