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

db.session.remove() in celery post run hook #2724

Merged
merged 1 commit into from
Sep 28, 2023
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
1 change: 1 addition & 0 deletions backend/geonature/celery_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

app.Task = ContextTask

app.conf.imports += ("geonature.tasks",)

Check warning on line 17 in backend/geonature/celery_app.py

View check run for this annotation

Codecov / codecov/patch

backend/geonature/celery_app.py#L17

Added line #L17 was not covered by tests
app.conf.imports += tuple(
[ep.module for dist in iter_modules_dist() for ep in dist.entry_points.select(name="tasks")]
)
9 changes: 9 additions & 0 deletions backend/geonature/tasks/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from celery.signals import task_postrun

Check warning on line 1 in backend/geonature/tasks/__init__.py

View check run for this annotation

Codecov / codecov/patch

backend/geonature/tasks/__init__.py#L1

Added line #L1 was not covered by tests

from geonature.utils.env import db
from geonature.utils.celery import celery_app

Check warning on line 4 in backend/geonature/tasks/__init__.py

View check run for this annotation

Codecov / codecov/patch

backend/geonature/tasks/__init__.py#L3-L4

Added lines #L3 - L4 were not covered by tests


@task_postrun.connect
def close_session(*args, **kwargs):
db.session.remove()

Check warning on line 9 in backend/geonature/tasks/__init__.py

View check run for this annotation

Codecov / codecov/patch

backend/geonature/tasks/__init__.py#L7-L9

Added lines #L7 - L9 were not covered by tests
Loading