svaante / dape

Debug Adapter Protocol for Emacs
GNU General Public License v3.0
448 stars 25 forks source link

How to stop at a breakpoint in a Django project? #91

Closed kjnez closed 4 months ago

kjnez commented 5 months ago

I followed https://github.com/svaante/dape/issues/23 using the simple example in here. It seems to be working for me when I issue "M-x dape" directly in a buffer. But I failed to attach to it when running python in terminal and issue "M-x dape" in Emacs. The error is:

SystemExit: 1 RuntimeError (note: full exception trace is shown but execution is paused at: _run_module_as_main): Can't listen for client connections: [Errno 98] Address already in use

More generally, if I have a more complex project like a django project, I can insert breakpoint() in a python file and when running the server, in terminal it will stop at the breakpoint that I set. How to achieve that with Dape? I tried to do the same thing as in the simple example above, but got the same error.

svaante commented 4 months ago

Can't listen for client connections: [Errno 98] Address already in use

import debugpy
debugpy.listen(("localhost", 5678)) # << This port is already taken

I would not recommend debugging by importing debugpy if it's not strictly necessary, it's much easier to let debugpy launch the application you want to debug.

bild

kjnez commented 4 months ago

Thanks for the clarification. Maybe consider adding it to README or the wiki? When I read the descriptions there I never thought what you mentioned above was the preferred way.