使用pdb调试Python时引发BdbQuit [英] BdbQuit raised when debugging Python with pdb
问题描述
最近在将 pdb
调试器添加到我的Python 2.7.10代码中时,出现以下消息:
跟踪(最近一次通话最近):
文件 /Users/isaachess/Programming/vivint/Platform/MessageProcessing/vivint_cloud/queues/connectors/amqplib_connector.py,第191行,位于acking_callback
callback(message.body)
文件 /Users/isaachess/Programming/vivint/Platform/MessageProcessing/vivint_cloud/queues/consumable_message_queue.py,第32行,位于反序列化回调
self._callback_method中(msg)
文件 /Users/isaachess/Programming/vivint/Platform/BusinessLogic/businesslogic/util/statsd_util.py,第95行,在_time_func中
retVal = f(* args,** kwargs)
文件 /Users/isaachess/Programming/vivint/Platform/MessageProcessing/vivint_cloud/net/router.py,在句柄
中尝试:
文件 /用户/ isaachess /编程/ vivint /平台/MessageProcessing/vivint_cloud/net/router.py&qu ot ;,第226行,在句柄
中尝试:
文件 /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/bdb.py,第49行,在trace_dispatch
中返回self.dispatch_line(frame)
文件 /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/bdb.py,第68行,在dispatch_line
,如果self.quitit:引发BdbQuit
BdbQuit
这是在插入行之后: / p>
import pdb;代码中的pdb.set_trace()
。
我不知道为什么会这样。我已经阅读了Bdb和Bdbquit,但无法弄清楚为什么这会在我的代码中发生。谁能为我提供一些提示,说明为什么这种情况普遍发生?我真的想让调试器重新工作。
我离开时遇到了这个问题 import pdb
和生产代码中的 pdb.set_trace()
。当执行 pdb.set_trace()
行时,python正在等待我的输入将其告诉 c
ontinue或进入等...因为python代码是由Web服务器调用的,所以我不在那里按 c
继续。这么长时间(不确定多长时间)后,它终于引发了 BdbQuit
异常。
我什么都没有设置以捕获该异常,因此它在我的Web服务器中引发了500。
我花了一段时间才了解到我在后台程序/后台运行的调试代码导致了问题。我觉得很傻。
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.
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 c
ontinue 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.
这篇关于使用pdb调试Python时引发BdbQuit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!