Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCT-1643: Teardown session after request finished #219

Merged
merged 2 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 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.config.from_object(config)

register_extensions(app)
Expand Down
7 changes: 7 additions & 0 deletions backend/startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# we prevent this monkeypatching

import os
from app.extensions import db

os.environ["EVENTLET_NO_GREENDNS"] = "yes"
import eventlet # noqa
Expand All @@ -20,5 +21,11 @@

app = create_app()


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


if __name__ == "__main__":
eventlet.wsgi.server(eventlet.listen(("0.0.0.0", 5000)), app, log=app.logger)
Loading