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.
Whenever you want to leave the pdb console, type the command quit or exit . If you would like to explicitly restart a program at any place within the program, you can do so with the command run .
set_trace() at the corresponding line in the Python code and execute it. The execution will stop at the breakpoint. An interactive shell (the pdb shell) will appear and allows you to run regular Python code, i.e. to print the current contents of variables and data structures.
Disable the breakpoint. from pdb, just type disable N, where N is the breakpoint number you are stuck on. If you don't know the number of your troubling breakpoint, enter tbreak.
The breakpoint will stop your program just before it executes any of the code on that line. Set a breakpoint at line linenum in source file filename . Set a breakpoint at entry to function function found in file filename .
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With