Hacker News new | ask | show | jobs
by davidism 4548 days ago
To solve this, I have a custom Celery instance that wraps each task in my flask app's context. So you can treat celery tasks as just another request.
1 comments

Yeap, that's what i did as well, and i think that's the documented way ( using a flask test request context i think). But having to do this let me understand a lot more about sqlalchemy session, flushing and object states, in a multithreaded environment. I recommend doing that for an in-depth understanding.