Not able to get debugpy attach (PID and host & port) working inside Zed code editor
@StellaHuang95 đang làm issue này rồi.
Từ ngày 29/1/2025.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
Hi debugpy team,
I'm one of the guys that is working on the client-side implementation of the DAP spec for the Zed code editor.
We are struggling a bit to get the attach (PID and host & port) feature to work, and haven't found any documentation on how to do it.
Could you please point me in the right direction to find out how to configure debugpy to work with attach?
About our implementation:
We use the debugpy library that is installed inside the user’s virtual environment. We start the debug adapter with the following command:
path/to/python debugpy.adapter --port=1234 --host=localhost
Our Setup
We start a simple Python script with the following commands:
mkdir test-python-project
cd test-python-project
python3 -m venv ./.venv
source ./.venv/bin/activate
pip install debugpy
touch test.py
Add the following content to the test.py file:
x = 1 // added breakpoint here
print("Script has started")
while True:
x += 1
Start to listen for debugger:
debugpy --listen localhost:5678 --wait-for-client test.py
Our Issue
So one of the issues we are facing is that we never receive an attach response back, so it seems like debugpy is waiting for something/someone. So I looked at our request/response log which shows that we receive two custom events debugpySockets and debugpyWaitingForServer. Which results into the following error log Cancelled DAP request for "attach" id 2 which took over 12s.
Which to my understanding is not more than just an informational event, to notify us about the sockets it is listening on and that it is waiting for a server to connect to it. So while I was debugging this issue, I looked at the vscode-python-debugger implementation, it seems like they don't really act on these events.
So my first question is should we act on these events? And if so, how should we act on them?
I also read through some of the debugpy internal code, which seems to support the StartDebuggingRequest reverse request, so should we act on these events if we could receive the StartDebuggingRequest request?
I've seen examples online where two instances of debugpy are run, one for the debuggee program and another to connect to the first instance. Is this a pattern that we'll have to replicate?
Request log for debugpy attach
// Send
{
"type": "request",
"seq": 1,
"command": "initialize",
"arguments": {
"clientID": "zed",
"clientName": "Zed",
"adapterID": "debugpy",
"locale": "en-US",
"linesStartAt1": true,
"columnsStartAt1": true,
"pathFormat": "path",
"supportsVariableType": true,
"supportsVariablePaging": false,
"supportsRunInTerminalRequest": true,
"supportsMemoryReferences": true,
"supportsProgressReporting": false,
"supportsInvalidatedEvent": false,
"supportsMemoryEvent": false,
"supportsArgsCanBeInterpretedByShell": false,
"supportsStartDebuggingRequest": true
}
}
// Receive
{
"seq": 1,
"type": "event",
"event": "output",
"body": {
"category": "telemetry",
"output": "ptvsd",
"data": {
"packageVersion": "1.8.12"
}
}
}
{
"seq": 2,
"type": "event",
"event": "output",
"body": {
"category": "telemetry",
"output": "debugpy",
"data": {
"packageVersion": "1.8.12"
}
}
}
{
"seq": 3,
"type": "event",
"event": "debugpySockets",
"body": {
"sockets": [
{
"host": "127.0.0.1",
"port": 52653,
"internal": false
}
]
}
}
{
"seq": 4,
"type": "response",
"request_seq": 1,
"success": true,
"command": "initialize",
"body": {
"supportsCompletionsRequest": true,
"supportsConditionalBreakpoints": true,
"supportsConfigurationDoneRequest": true,
"supportsDebuggerProperties": true,
"supportsDelayedStackTraceLoading": true,
"supportsEvaluateForHovers": true,
"supportsExceptionInfoRequest": true,
"supportsExceptionOptions": true,
"supportsFunctionBreakpoints": true,
"supportsHitConditionalBreakpoints": true,
"supportsLogPoints": true,
"supportsModulesRequest": true,
"supportsSetExpression": true,
"supportsSetVariable": true,
"supportsValueFormattingOptions": true,
"supportsTerminateRequest": true,
"supportsGotoTargetsRequest": true,
"supportsClipboardContext": true,
"exceptionBreakpointFilters": [
{
"filter": "raised",
"label": "Raised Exceptions",
"default": false,
"description": "Break whenever any exception is raised."
},
{
"filter": "uncaught",
"label": "Uncaught Exceptions",
"default": true,
"description": "Break when the process is exiting due to unhandled exception."
},
{
"filter": "userUnhandled",
"label": "User Uncaught Exceptions",
"default": false,
"description": "Break when exception escapes into library code."
}
],
"supportsStepInTargetsRequest": true
}
}
// Send
{
"type": "request",
"seq": 2,
"command": "attach",
"arguments": {
"request": "attach",
"cwd": "/Users/remcosmits/Documents/code/test-python-project",
"type": "debugpy",
"logToFile": true,
"connect": {
"host": "localhost",
"port": 5678
},
"clientOS": "unix",
"justMyCode": true,
"showReturnValue": true,
"workspaceFolder": "/Users/remcosmits/Documents/code/test-python-project"
}
}
// Receive
{
"seq": 5,
"type": "event",
"event": "debugpySockets",
"body": {
"sockets": [
{
"host": "127.0.0.1",
"port": 52653,
"internal": false
},
{
"host": "127.0.0.1",
"port": 52656,
"internal": true
}
]
}
}
{
"seq": 6,
"type": "event",
"event": "debugpyWaitingForServer",
"body": {
"host": "127.0.0.1",
"port": 52656
}
}
- Ngôn ngữ chính
- Python
- Star
- 2.5k
- Fork
- 205
- Merge trung bình
- 1 ngày 5 giờ
- Pull request đã merge (30 ngày)
- 4
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoft/debugpy
-
pydevd_comm.py start_client() does not set TCP_NODELAY on the connections it opensCó thể đã có người làm @nightcityblade đã nhận 52 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Document "rules"-optionCó thể đã có người làm @nightcityblade đã nhận 41 ngày trước. Đang mởdocumentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
wx.EventLoop() deprecation warningCó thể đã có người làm @nightcityblade đã nhận 39 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
debugpy.configure(python=) is not properly documentedCó thể đã có người làm @nightcityblade đã nhận 50 ngày trước. Đang mởdocumentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
-
Adapter bootstrap fails with ConnectionRefusedError on WSL2 VirtioProxy or hostAddressLoopbackCó thể đã có người làm @nightcityblade đã nhận 6 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
Tất cả issue của microsoft/debugpy
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Clean up dependabot noiseĐang mởTask
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
war-and-code/dircue#200 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 87/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày