Problem debugging with pdb

60 views
Skip to first unread message

Joshua Russo

unread,
May 15, 2009, 5:00:46 PM5/15/09
to Django users
(strangely my previous post seems to have disappeared so here we go
again)

I can't seem to get pdb to stop at my break points for a page request.
I start it like so:

(from the directory containing manage.py) python -m pdb manage.py
runserver

The debugger starts up properly, paused on the first line. I set my
two break points and they seem to save properly.

I let the debugger continue through opening the test server, but when
I request my page it's not stopping at my break points. I know it
should because I have the same setup in NetBeans and the break points
are hit. I'm trying to avoid using NB though because I'm on a PIII 350
w/ 256 Megs of ram. I think the lack of horse power is exacerbating
some bugs in the Python plug-in.

I saw some other posts about people using pdb so I'm assuming that
there is some way to get it to work. What am I doing wrong?

Thanks
Josh

Sam Chuparkoff

unread,
May 15, 2009, 6:44:24 PM5/15/09
to django...@googlegroups.com
On Fri, 2009-05-15 at 14:00 -0700, Joshua Russo wrote:
> I can't seem to get pdb to stop at my break points for a page request.
> I start it like so:
>
> (from the directory containing manage.py) python -m pdb manage.py
> runserver

Have you tried this?

python -m pdb manage.py runserver --noreload

If that's not the problem I don't have a clue.

sdc


Joshua Russo

unread,
May 16, 2009, 9:07:22 AM5/16/09
to Django users
Ok I figured it out. I'm not exactly sure what the b or break command
within pdb does but it doesn't seem to work in some instances as I
described in my initial post. Does anyone know what the constraints
are to using the break command within pdb?

What does work is to import pdb in the file you want to debug and then
place the command pdb.set_trace() where you want to start debugging.
This is an excellent quick tutorial for anyone who is interested:
http://www.ferg.org/papers/debugging_in_python.html

It explains the commands bit better than the pdb docs do. I had
actually found this site about a week ago and completely forgot about
it.

sadach

unread,
May 16, 2009, 5:04:22 PM5/16/09
to Django users
On May 16, 9:07 am, Joshua Russo <joshua.rupp...@gmail.com> wrote:
> Does anyone know what the constraints
> are to using the break command within pdb?

Autoreload spawns a new python interpreter. Nothing survives. So don't
use autoreload.

Another caveat: if you try to set a breakpoint and pdb can't find the
file, it's probably because you are relying on django to tinker with
sys.path, and that just hasn't happened yet.

sdc
Reply all
Reply to author
Forward
0 new messages