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
@app.teardown_request function doesn't called in debug mode [NOT-A-BUG] #661
Comments
What Flask version are you using? I just ran your example, and with |
There's a pull request for flask-sqlalchemy that implements commit on app teardown, would you consider testing and helping improve it? |
Thanks for review!
(FYI: if you uncomment commented lines and comment "@app.route('/')" /How I actually do in my app/ issue reproduced too)
My current workaround is
Your flask-sqlalchemy pull-request looks awesome! I will try it soon and comment on it. PS: flask also doesn't trigger @app.errorhandler(500) in debug mode, but I think that fact should be documented. |
Same as the first example, |
Just discower that this issue is reproduced if I run
I also add datetime.datetime.now() to print statement. Looks like This is very strange behaviour. Anyway, if id doesn't called at all - this is not what I expect. I realised that I doesn't need to call rollback explicitly, because
So it can be replaced by
|
I discover, that this behaviour is little documented there http://flask.pocoo.org/docs/config/#builtin-configuration-values So, the following piece of code fixes my issue
But I think this should be documented there http://flask.pocoo.org/docs/api/#flask.Flask.teardown_request too! |
FYI, this also affects the teardown_appcontext. This is also the method that is mentioned in the SQLAlchemy setup doc page: http://flask.pocoo.org/docs/0.10/patterns/sqlalchemy/ So might want to add a note there too: |
UPD: not a bug, see #661 (comment)
So, when I open index page and see 500 error page, console output is
ValueError('test exc')
. But when I start app in debug mode, egOutput is
None
, when expectedValueError('test exc')
.This is important for me, because I use
teardown_request
for sqlalchemy transaction management likeThe text was updated successfully, but these errors were encountered: