Changeset - d654adfc5898
[Not reviewed]
default
0 1 0
Mads Kiilerich - 6 years ago 2019-11-16 16:57:27
mads@kiilerich.com
Grafted from: 2d78f82822bc
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.
1 file changed with 3 insertions and 0 deletions:
0 comments (0 inline, 0 general)
kallithea/config/app_cfg.py
Show inline comments
 
@@ -31,12 +31,13 @@ from sqlalchemy import create_engine
 
from tg import hooks
 
from tg.configuration import AppConfig
 
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
 
from kallithea.lib.middleware.simplehg import SimpleHg
 
from kallithea.lib.middleware.wrapper import RequestWrapper
 
from kallithea.lib.utils import check_git_version, load_rcextensions, make_ui, set_app_settings, set_indexer_config, set_vcs_config
 
@@ -178,12 +179,14 @@ def setup_configuration(app):
 
    # kallithea.CONFIG).
 
    set_vcs_config(kallithea.CONFIG)
 
    set_indexer_config(kallithea.CONFIG)
 

	
 
    check_git_version()
 

	
 
    kallithea.model.meta.Session.remove()
 

	
 

	
 
hooks.register('configure_new_app', setup_configuration)
 

	
 

	
 
def setup_application(app):
 
    config = app.config
0 comments (0 inline, 0 general)