Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there anyway to get pdb and Mac Terminal to play nicely?

When debugging my django apps I use pdb for interactive debugging with pdb.set_trace().

However, when I amend a file the local django webserver restarts and then I cant see what I type in the terminal, until I type reset.

Is there anyway for this to happen automatically? It can be real annoying, having to cancel the runserver and reset and restart it all the time. I'm told it doesn't happen on other OS's (ubuntu) so is there anyway to make it not happen on the Mac? (I'm using Snow Leopard).

like image 253
Ross Avatar asked Apr 29 '10 08:04

Ross


People also ask

How do I break out of pdb?

To start execution, you use the continue or c command. If the program executes successfully, you will be taken back to the (Pdb) prompt where you can restart the execution again. At this point, you can use quit / q or Ctrl+D to exit the debugger.

How do you continue after pdb?

After some scientifically-crafted experimentation, turns out ctrl+Z haults the pdb shell. (Then stty sane to fix the Enter key.) Then you need to kill or resume the pdb shell. To do so, run jobs , then either fg 1 or kill %1 (substituting the job number).

How do I stop Python debugging?

Pausing or Stopping the Debugger To pause a running script, click the Pause button . At this point you can click the Start button to continue running the script, click the Step button to execute the highlighted line of code, or execute additional Python commands.

Why do we need PDB file?

pdb file holds debugging and project state information that allows incremental linking of a Debug configuration of your app. The Visual Studio debugger uses . pdb files to determine two key pieces of information while debugging: The source file name and line number to display in the Visual Studio IDE.


1 Answers

OK - this works for me I created a ~/.pdbrc and added

import os
os.system("stty sane")

Now each time pdb is run it sets the line settings back to sane.

If I fall out to the terminal then I still have to do it manually - but it solves having to quit runserver and reset all the time.

like image 187
Ross Avatar answered Sep 20 '22 20:09

Ross