Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BdbQuit raised when debugging Python with pdb

Recently when adding the pdb debugger to my Python 2.7.10 code, I get this message:

Traceback (most recent call last):   File "/Users/isaachess/Programming/vivint/Platform/MessageProcessing/vivint_cloud/queues/connectors/amqplib_connector.py", line 191, in acking_callback     callback(message.body)   File "/Users/isaachess/Programming/vivint/Platform/MessageProcessing/vivint_cloud/queues/consumable_message_queue.py", line 32, in deserialized_callback     self._callback_method(msg)   File "/Users/isaachess/Programming/vivint/Platform/BusinessLogic/businesslogic/util/statsd_util.py", line 95, in _time_func     retVal = f(*args, **kwargs)   File "/Users/isaachess/Programming/vivint/Platform/MessageProcessing/vivint_cloud/net/router.py", line 226, in handle     try:   File "/Users/isaachess/Programming/vivint/Platform/MessageProcessing/vivint_cloud/net/router.py", line 226, in handle     try:   File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/bdb.py", line 49, in trace_dispatch     return self.dispatch_line(frame)   File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/bdb.py", line 68, in dispatch_line     if self.quitting: raise BdbQuit BdbQuit 

This is after inserting the line:

import pdb; pdb.set_trace()

in the code.

I cannot figure out why this is happening. I've read up on Bdb and Bdbquit, but cannot figure out why this is happening in my code. Can anyone provide me with some hints of why this happens in general? I really want to get the debugger working again.

like image 872
isaachess Avatar asked Jan 21 '16 03:01

isaachess


People also ask

Is pdb a debugging module in Python?

The module pdb defines an interactive source code debugger for Python programs. It supports setting (conditional) breakpoints and single stepping at the source line level, inspection of stack frames, source code listing, and evaluation of arbitrary Python code in the context of any stack frame.

How do I use pdb debugger in Python?

Starting Python Debugger To start debugging within the program just insert import pdb, pdb. set_trace() commands. Run your script normally and execution will stop where we have introduced a breakpoint. So basically we are hard coding a breakpoint on a line below where we call set_trace().


1 Answers

I ran into this when I left import pdb and a pdb.set_trace() in my production code. When the pdb.set_trace() line was executed, python was waiting for my input to tell it to continue or step into, etc... Because the python code was being called by a web server I wasn't there to press c to continue. After so long (not sure how long) it finally raised the BdbQuit exception.

I didn't have anything setup to catch that exception so it raised a 500 in my web server.

It took me a while to understand that my debug code running in an a daemon/background was causing the issue. I felt silly.

like image 77
teewuane Avatar answered Sep 21 '22 14:09

teewuane