Last active
December 25, 2015 00:09
-
-
Save satiani/6885252 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rom flask import Flask | |
app = Flask(__name__) | |
@app.teardown_request | |
def teardown(exc = None): | |
if exc is not None: | |
print "An exception has occured!" | |
try: | |
with app.test_request_context(): | |
raise Exception('dummy') | |
except: | |
pass | |
# uncomment this to remove the issue | |
# import sys; sys.exc_clear() | |
with app.test_request_context(): | |
print "Nothing happening here" | |
# Output: | |
# An exception has occured! | |
# Nothing happening here | |
# An exception has occured! <== this is unexpected! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment