views:

55

answers:

3

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).

A: 

Try to [q]uit pdb before you save changes to a file. This will keep the console from wigging out on you but only for that one run of pdb.set_trace().

You will still have to fallback to the old ^C + reset + ./manage.py runserver when you forget to quit pdb. One thing that can make the reset a little less annoying is to put the reset and runserver onto one line. That way the reset is just a quick ^Rreset or up-arrow away.

[ ... ]
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
^C$ reset && ./manage.py runserver
istruble
A: 

The best I've found is doing a reset inside pdb like so:

import os; os.system("reset");

Ross
A: 

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.

Ross