Skip to content

Instantly share code, notes, and snippets.

@satiani
Last active December 25, 2015 00:09
Show Gist options
  • Save satiani/6885252 to your computer and use it in GitHub Desktop.
Save satiani/6885252 to your computer and use it in GitHub Desktop.
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