2

我有父进程调用它的子进程。我放了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:
4

1 回答 1

5

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

于 2013-06-15T11:05:20.780 回答