Breakpoints don't work in threads created after `debugpy.listen()` is called
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 52/100
Hướng nghiên cứu
Bắt đầu bằng cách chạy bản tái hiện được cung cấp multithread_debugging.py với start_listener_at_index=5 và so sánh các breakpoint của GUI với breakpoint(). Theo dõi việc thiết lập thread xung quanh debugpy.listen(); hoàn tất khi các breakpoint của GUI được chạm tới trong các thread được khởi chạy cả trước và sau listen, phù hợp với hành vi mong đợi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Environment data
- debugpy version: 1.8.14 / 1.8.17
- OS and version: Mac OS 15.6.1
- Python version (& distribution if applicable, e.g. Anaconda): 3.10.12
- Using VS Code or Visual Studio: Visual Studio Code Version: 1.104.1
Actual behavior
In threads which are started (via threading.Thread.start()) after the call to debugpy.listen(), breakpoints will not work.
Expected behavior
Breakpoints should work in all threads, regardless of when they are started.
Steps to reproduce:
- Use the following script:
# multithread_debugging.py
import sys
import threading
from queue import Queue
import debugpy
threads: list[threading.Thread] = []
queues: list[Queue] = []
N_THREADS = 10
POISON_PILL = -1
def handler(q: Queue):
while True:
item = q.get()
print(threading.current_thread(), item)
if item == POISON_PILL:
print(threading.current_thread(), "exiting")
return
def send(i: int, item):
queues[i].put(item)
def end(i: int, *, wait=False):
send(i, POISON_PILL)
if wait:
threads[i].join()
def end_all():
for i in range(N_THREADS):
end(i)
for t in threads:
t.join()
print("all done")
if __name__ == "__main__":
start_listener_at_index = 0
if len(sys.argv) >= 2:
start_listener_at_index = int(sys.argv[1])
for i in range(10):
q = Queue()
t = threading.Thread(target=handler, args=[q])
threads.append(t)
queues.append(q)
for i, t in enumerate(threads):
if i == start_listener_at_index:
print(f"starting debug listener before thread {i} starts")
debugpy.listen(("0.0.0.0", 5680))
t.start()
- Add the following launch configuration:
{
"name": "Attach to multithreading example",
"type": "debugpy",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5680
}
},
- Run
python -i multithread_debugging.py 5 - Add a breakpoint on the print statement in the
handler()method. - Run the "Attach to multithreading example" debug configuration.
- In the REPL, run:
send(0, "foo"). Note that the breakpoint is not triggered. - In the REPL, run:
send(4, "foo"). Note that the breakpoint is not triggered. - In the REPL, run
send(5, "foo"). Note that the breakpoint IS triggered (because thread 5 is started after the debugpy listen call).
Further notes
If you set the breakpoint using the breakpoint() function, it works in all threads. However, if you set it using the vscode GUI, you get the buggy behaviour described above.
- Ngôn ngữ chính
- Python
- Star
- 2.5k
- Fork
- 202
- Merge trung bình
- 5 ngày 1 giờ
- Pull request đã merge (30 ngày)
- 1
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
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Document "rules"-option Đang mởdocumentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
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 hostAddressLoopback Đ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ự
-
essnmx good first issue
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 95/100
-
[Feature] 奇物选择添加优先级 Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
syfoud/Simulated_Scepter#174 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Giskard-AI/giskard-oss#2840 · 1 bình luận ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success Đang mởarea: repo bug perceived difficulty: 2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
yeti-platform/yeti#1380 ·