set_trace() only works the first time
See original GitHub issueThe breakpoint (as in import web_pdb; web_pdb.set_trace()
) works fine for the first time.
But once the debugger session is ended (e.g. by typing c
and pressing enter
), it won’t stop again until the dev server is restarted. By “won’t stop” I mean the breakpoint no longer works.
I’m using Django==1.11.22 and web-pdb==1.5.1 in a Docker container. The breakpoint was inserted in the beginning of a view function.
def view_func(request):
import web_pdb; web_pdb.set_trace()
...
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (7 by maintainers)
Top Results From Across the Web
sys.settrace only getting called at function calls, not every line
The trace function is invoked (with event set to 'call') whenever a new local scope is entered; it should return a reference to...
Read more >The unreasonable effectiveness of sys.settrace (and ... - expLog
settrace sets a trace function that is triggered by the VM every time it enters or exits a function, processes a line of...
Read more >sys — System-specific parameters and functions — Python ...
Get the trace function as set by settrace() . CPython implementation detail: The gettrace() function is intended only for implementing debuggers, profilers, ...
Read more >Python Debugging With Pdb
In this first example, we'll look at using pdb in its simplest form: checking the value of a variable. Insert the following code...
Read more >Usage and Invocations — pytest documentation
pytest -x # stop after first failure pytest --maxfail=2 # stop after two ... format pytest --tb=line # only one line per failure...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey folks, I spent this afternoon poking into this, and I think it is not a container issue, but rather a webpdb-and-threads issue. I was able to reproduce the issue locally with this toy flask app.
As far as I can tell, when webpdb exits due to a thread closing (which in most Python webserver frameworks is going to happen at the end of any web request), it leaves out a bit of cleanup; whenever the
set_trace()
command is hit subsequently, webpdb thinks that it’s still running (because of the neglected cleanup step from before) and so doesn’t refresh the web console connection, so the debugger doesn’t work.Opening a PR now.
Closing this because of no further feedback.