PDB won't stop on breakpoint
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.
I usually prefer set_trace()
in the source itself, that way the dev server will reload when added/removed, and I don't need to stop and start it again. For example:
def get_item(request):
import pdb; pdb.set_trace()
When the view is accessed, pdb will kick in.
When I've seen this problem in the past, it's usually because someone has set the breakpoint on a line that is not actually connected to a Python statement that is run. For example, blank lines, comment lines, the wrong part of a multi-line statement.