level12 / keg-app-cookiecutter

0 stars 0 forks source link

remove celery task post-run #201

Closed guruofgentoo closed 1 year ago

guruofgentoo commented 1 year ago

https://github.com/level12/keg-app-cookiecutter/blob/master/%7B%7Bcookiecutter.src_dirname%7D%7D/%7B%7Bcookiecutter.project_pymod%7D%7D/celery/app.py#L20

Flask-SQLAlchemy 3+ has changed to scoping db sessions to the flask app context, rather than the thread. So, each celery task will get a fresh db session from the way we wrap tasks with an app context. The side-effect to this is, when the app context exits, FSA will remove the session for us, and we no longer need to do this manually.