Skip to content

Commit

Permalink
OCT-1643: Teardown session after request finished
Browse files Browse the repository at this point in the history
  • Loading branch information
kgarbacinski committed May 16, 2024
1 parent 0344935 commit 8cf2143
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions backend/app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from flask import Flask

from app.engine.epochs_settings import register_epoch_settings
from app.extensions import (
db,
migrate,
Expand All @@ -13,12 +14,11 @@
init_scheduler,
init_subgraph,
)
from app.logging import init_logger
from app.infrastructure import events, routes, apscheduler # noqa
from app.infrastructure.exception_handler import ExceptionHandler
from app.settings import ProdConfig, DevConfig
from app.engine.epochs_settings import register_epoch_settings
from app.logging import init_logger
from app.modules.registry import register_services
from app.settings import ProdConfig, DevConfig


def create_app(config=None):
Expand All @@ -31,6 +31,7 @@ def create_app(config=None):
template_folder=f"{config.PROJECT_ROOT}/templates",
static_folder=f"{config.PROJECT_ROOT}/static",
)
app.teardown_request(teardown_session)
app.config.from_object(config)

register_extensions(app)
Expand All @@ -57,3 +58,7 @@ def register_extensions(app):
def register_errorhandlers(app):
handler = ExceptionHandler()
app.register_error_handler(Exception, handler)


def teardown_session(*args, **kwargs):
db.session.remove()

0 comments on commit 8cf2143

Please sign in to comment.