PDB won't stop on breakpoint

Raphael picture Raphael · Oct 1, 2011 · Viewed 8.7k times · Source

I'm quite new with debugging directly with pdb and I am having some issues debugging my Django application. Here is what I'm doing:

python -m pdb manage.py runserver
(pdb) b core/views.py:22
Breakpoint 2 at /Users/raphaelcruzeiro/Documents/Projects/pdb_test/core/views.py:22
(Pdb) c

However the execution passes directly through the breakpoint. Am I missing some command? The manual doesn't elaborate on setting a breakpoint anymore than this.

Answer

Gustavo Meira picture Gustavo Meira · Feb 2, 2015

I've been through the same problem.

Try something like python -m pdb ./manage.py runserver --nothreading --noreload 127.0.0.1:8080. It solved the issue for me.

It seems that breakpoints with PDB are thread-specific, and the --nothreading and --noreload options are necessary to avoid some forking that may confuse PDB. This is also why set_trace works, as it's called directly inside the thread of interest.