“Graphical” Django Debugging Without the Fatties
Sometimes you need to see more at one time than pdb will show you, but you don’t want to run Eclipse or Komodo because they are way overkill. Something in between would work. Something like… pudb!
However, trying to drop pudb in a Django app:
from pudb import set_trace; set_trace()
throws an error:
ValueError: signal only works in main thread
because, it turns out, signals only work in the main thread of a Python application. Informative, but not helpful. Luckily, there’s a simple solution. pudb apparently uses urwid for its GUI, which is causing the problem. The PuDB wiki has the answer.
To fix it, simply find where urwid was installed (when you easy_install’d pudb). For me on OSX it was in /Library/Python/2.5/site-packages/. Once you’ve found it, edit the raw_display.py file. Find the function definitions:
def signal_init(self)
def signal_restore(self)
Edit the functions so they are just:
pass
That’s it! Dropping a set_trace() shows an excellent, console-based gui for your viewing pleasure.
Now go have fun out there.