Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Teardown app context vs. request context #99

alexex opened this Issue · 1 comment

3 participants


According to L672 flask-sqlalchemy uses teardown_appcontext if available and not teardown_requestcontext. I would actually like to know what thought was behind this, as the sqlalchemy docs suggest to close/remove/rollback the session after every request (see

In my opinion this can lead to problems with pool_recycle as not all connections are always returned to the pool (at least my sqlalchemy log looked like it) and so the pool won't be recycled. But I might be wrong.


When handling a request, the app context has a similar lifecycle to the request context, so tying the session to the app context makes sense.

@immunda immunda closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.