-
How to ensure each request has it's own db.session in flask-sqlalchemy app using celery and postgresql and being run by gunicorn?See below the errors I am getting, the code I am using, and the logs showing the same session being shared across requests. Software Versions
ErrorsIn Postgresql
In SQLAlchemy
CodeIn
|
Beta Was this translation helpful? Give feedback.
Answered by
shawnim
Apr 19, 2025
Replies: 1 comment
-
For Celery worker db sessions I used this in
For Flask REST API request db sessions I used this in
It's not perfect but it's working much better. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
shawnim
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For Celery worker db sessions I used this in
myapp/__init__.py
: