pdb在调用pdb.set_trace()后没有响应

时间:2013-06-13 07:13:03

标签: python debugging pdb

我有父进程调用它的子进程。我已将import pdb; pdb.set_trace()放入子流程代码中。

当我使用python -m pdb parent.py启动父级时,它会被冻结。调试器不响应我输入的任何命令。但是,当我点击quitcontinue时,它会退出代码。

看起来pdb有效,但不会产生任何输出。

$ python -m pdb parent.py
n -m pdb parent.py
> d:\scripts\parent.py(53)<module>()
-> '''
(Pdb) c

现在停止响应。

根据我在中断后得到的踪迹,它在pdb.set_trace()电话之后就站在了线上。

>>>>>>>>>>>>>[2013.06.13-10:02:06] : accessed by child.py
Traceback (most recent call last):
File "child.py", line 40, in <module>
    sys.stderr = open(Definition_h.ErrLog, 'a', 0, encoding=Definition_h.utf8)
File "d:\scripts\Definition_h.py", line 863, in unicodeOpen
    def unicodeOpen(*args, **kwargs):
File "C:\Program Files (x86)\Python 2.5.4\lib\bdb.py", line 50, in trace_dispatch
    return self.dispatch_call(frame, arg)
File "C:\Program Files (x86)\Python 2.5.4\lib\bdb.py", line 79, in dispatch_call
    self.user_call(frame, arg)
File "C:\Program Files (x86)\Python 2.5.4\lib\pdb.py", line 134, in user_call
    self.interaction(frame, None)
File "C:\Program Files (x86)\Python 2.5.4\lib\pdb.py", line 187, in interaction
    self.cmdloop()
File "C:\Program Files (x86)\Python 2.5.4\lib\cmd.py", line 148, in cmdloop
    import readline
KeyboardInterrupt: !!!<unprintable KeyboardInterrupt object>
Error in sys.excepthook:

1 个答案:

答案 0 :(得分:3)

实际上问题是我的代码是将sys.stdout重定向到日志文件