Attach to debugpy #846
-
I'm trying to attach to a debugpy server started by the python process itself but can't get it working for some reason. I'm pretty new to this so probably doing something wrong and was wondering if someone might have some ideas. Basically I'm running: # tmp.py
x = 5
import debugpy
debugpy.listen(38000)
debugpy.wait_for_client()
debugpy.breakpoint() and then I'm runnning # tmp.lua
local dap = require('dap')
dap.run({
name = 'Attach',
type = 'python',
request = 'attach',
port = 38000,
server = '127.0.0.1',
pythonPath = 'python',
console = 'integratedTerminal',
}) But I get:
and then
I can see the python process waiting for a client and that there is a port 38000 open. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
How does your adapter definition look like? debugpy is a bit special in regards to the attach handling. For most adapters you still launch the debug-adapter the same way, and then the debug-adapter attaches to the process. For Because of that you'll need to switch over to a adapter definition of type |
Beta Was this translation helpful? Give feedback.
-
same issue here. Any step by step help I could use? |
Beta Was this translation helpful? Give feedback.
How does your adapter definition look like? debugpy is a bit special in regards to the attach handling. For most adapters you still launch the debug-adapter the same way, and then the debug-adapter attaches to the process. For
debugpy
the process usingdebugpy.listen()
(or when usingpython -m debugpy --listen ...
) launches the service that speaks DAP.Because of that you'll need to switch over to a adapter definition of type
server
. I'd recommend to use nvim-dap-python which does that:https://github.com/mfussenegger/nvim-dap-python/blob/d4400d075c21ed8fb8e8ac6a5ff56f58f6e93531/lua/dap-python.lua#L130-L153