Skip to content

Instantly share code, notes, and snippets.

@tony
Forked from alonho/flask_pdb.py
Created April 2, 2018 21:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tony/cde2715fd0553aa1dde2f8aefe31339b to your computer and use it in GitHub Desktop.
Save tony/cde2715fd0553aa1dde2f8aefe31339b to your computer and use it in GitHub Desktop.
Flask: drop into pdb on exception
def drop_into_pdb(app, exception):
import sys
import pdb
import traceback
traceback.print_exc()
pdb.post_mortem(sys.exc_info()[2])
# somewhere in your code (probably if DEBUG is True)
flask.got_request_exception.connect(drop_into_pdb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment