homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Add non-interactive version of Bdb.runcall
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.5
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: etanol, georg.brandl
Priority: normal Keywords:

Created on 2015年01月27日 13:09 by etanol, last changed 2022年04月11日 14:58 by admin.

Messages (1)
msg234819 - (view) Author: Isaac Jurado (etanol) Date: 2015年01月27日 13:09
The Bdb.runcall method shows a prompt right at the beginning of the function. If breakpoints are defined, it is sometimes handy to skip the prompt until the next breakpoint, if any.
This use case came up in our development environment for a Django application, from where we needed to set breakpoints only for certain request, allowing other request to run without interruption. Our solution was to wrap with a WSGI middleware, something like this:
 import sys
 from bdb import BdbQuit
 from pdb import Pdb
 class DebuggingMiddleware(object):
 def __init__(self, app):
 self.aplicacion = app
 self.debugger = Pdb()
 our_setup_breakpoints_function(self.debugger)
 def __call__(self, environ, start_response):
 environ['DEBUGGER'] = self.debugger
 frame = sys._getframe()
 self.debugger.reset()
 frame.f_trace = self.debugger.trace_dispatch
 self.debugger.botframe = frame
 self.debugger._set_stopinfo(frame, None, -1)
 sys.settrace(self.debugger.trace_dispatch)
 try:
 return self.aplicacion(environ, start_response)
 except BdbQuit:
 pass # Return None implicitly
 finally:
 self.debugger.quitting = 1
 sys.settrace(None)
As you can see, it is basically a mix of Bdb.set_trace and Bdb.set_continue which we came up by trial and error. If there was something like Bdb.runcall_no_prompt or an extra flag to Bdb.runcall to trigger this behaviour, this copy and paste would not be necessary.
History
Date User Action Args
2022年04月11日 14:58:12adminsetgithub: 67520
2015年03月08日 16:11:55BreamoreBoysetnosy: + georg.brandl
2015年01月27日 13:09:19etanolcreate

AltStyle によって変換されたページ (->オリジナル) /