# HG changeset patch # User Mads Kiilerich # Date 2019-11-16 16:57:27 # Node ID d654adfc589857ee34e7b4db3d3f1d4b4be331df # Parent 394c7814e710ad56616e2490a0b74ebdd112c92a app: let app instance creation remove its SA Session when done The app instance is usually created early or on demand before serving the first request, and the app instance might sit idle for a while before receiving the first request. The app creation will touch the database, and we have to consider the lifetime of the database session it is using. The cbf524e4c1a3 commit message gives some reasons we should remove the session when done. But instead of handle it inside utility functions, we would rather handle sessions at a high level as here. diff --git a/kallithea/config/app_cfg.py b/kallithea/config/app_cfg.py --- a/kallithea/config/app_cfg.py +++ b/kallithea/config/app_cfg.py @@ -34,6 +34,7 @@ from tg.support.converters import asbool import kallithea.lib.locale import kallithea.model.base +import kallithea.model.meta from kallithea.lib.middleware.https_fixup import HttpsFixup from kallithea.lib.middleware.permanent_repo_url import PermanentRepoUrl from kallithea.lib.middleware.simplegit import SimpleGit @@ -181,6 +182,8 @@ def setup_configuration(app): check_git_version() + kallithea.model.meta.Session.remove() + hooks.register('configure_new_app', setup_configuration)