eduardo schettino  committed 249e06a

core. option to drop into PDB on internal-error.

  • Participants
  • Parent commits 1efc5c0
  • Branches default

Comments (0)

Files changed (1)

File avalanche/

             A sequence of :class:`Route` instances
         :param debug:
             True to enable debug mode, False otherwise.
+            If value is (string) 'pdb' enables post-mortem debug using PDB
+            on your terminal (if running on localhost only).
         :param error_handlers:
             A dictionary mapping HTTP error codes (int) to RequestHandler's
         if self.debug:
             detail = ''.join(traceback.format_exception(*sys.exc_info()))
+            # pdb post-mortem debug is enabled. so re-raise exception
+            if self.debug == 'pdb': # pragma: no cover
+                try:
+                    # try to use Ipython if available
+                    from IPython.ipapi import make_session; make_session()
+                    from IPython.Debugger import Pdb as IPdb
+                    Pdb = IPdb
+                except:
+                    from pdb import Pdb
+                debugger = Pdb(stdin=sys.__stdin__, stdout=sys.__stdout__)
+                debugger.set_trace(sys._getframe().f_back)
             detail = None