[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) <odo@openerp.com>
This commit is contained in:
Nils Hamerlinck
2021-07-07 13:17:03 +00:00
parent ef21b193cd
commit 5b3bf7254f
+11
View File
@@ -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)