Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
430 views
in Technique[技术] by (71.8m points)

python - How to quit ipdb while in post-mortem debugging?

I like to inspect error in a Python script by using:

$ python3 -m pdb my_script.py

This drops me into a pdb prompt from where I can c continue the execution, and when it hits error, I can inspect the variables and then q quit the script execution to get back to my shell.

I tried the same with iPython debugger module, since it is more colorful:

$ python3 -m ipdb my_script.py

However, I am not able to quit the debugger once I am done inspecting the error. Using the q quit command just keeps switching it between re-executing the script and post-mortem mode:

$ python3 -m ipdb my_script.py
ipdb> c
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
ipdb> Inspect some variables at this point
ipdb> q
Post mortem debugger finished. The my_script.py will be restarted
ipdb> q
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
ipdb> q
Post mortem debugger finished. The my_script.py will be restarted
ipdb> q
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
ipdb> q
Post mortem debugger finished. The my_script.py will be restarted
ipdb> q
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program

How to quit this debugger?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

As the user @ffeast commented, there is an open ipdb issue, and a few workarounds suggested. For me these worked well:

  • press ctrl+z and kill %1 (or whatever the Job number is)
  • execute ipdb> import os; os._exit(1)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...