Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 721
Ashwin Nanjappa Avatar asked Aug 23 '16 00:08

Ashwin Nanjappa


People also ask

How do I exit IPDB?

If you enter pdb interactive mode there is no way to return to ipdb or ipython. The proper way to exit is by using ctrl-d .


2 Answers

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)
like image 88
tutuDajuju Avatar answered Sep 22 '22 20:09

tutuDajuju


This was a bug in IPython 5.1. It was fixed in this pull request and is no longer an issue from IPython 5.2 and onwards. You can now use q, quit(), or Ctrl+d to exit the debugger.

like image 37
joelostblom Avatar answered Sep 23 '22 20:09

joelostblom