Pausing or adding new breakpoints halfway during running in VSCode makes the Python Exception lost
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
- 35/100
Hướng nghiên cứu
Bắt đầu bằng cách chạy ví dụ Python tối thiểu và tái hiện ba luồng VSCode: Pause, một breakpoint được đặt sẵn và thêm một breakpoint khi chương trình đang chạy. So sánh cách xử lý ngoại lệ thu được, đặc biệt là thông báo của callback sys.settrace; được xem là hoàn tất khi Pause và các breakpoint được thêm trong lúc chạy bắt được RuntimeError giống như breakpoint được đặt sẵn mà không để chương trình ở trạng thái tạm dừng.
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.13
- OS and version:
Linux abc 5.15.0-139-generic #149 ~20.04.1-Ubuntu SMP Wed Apr 16 08:29:56 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux - Python version (& distribution if applicable, e.g. Anaconda): Python 3.10.18 (miniconda 23.5.2)
- Using VS Code or Visual Studio: VSCode
Actual behavior
Pausing or adding new breakpoints halfway during debugging in VSCode seems to make the Python Exception uncaught.
The following is a minimal example to reproduce my problem.
import contextlib, signal
@contextlib.contextmanager
def time_limit(seconds):
def signal_handler(signum, frame):
raise RuntimeError("Timed out!")
signal.setitimer(signal.ITIMER_REAL, seconds)
signal.signal(signal.SIGALRM, signal_handler)
try:
yield
finally:
signal.setitimer(signal.ITIMER_REAL, 0)
if __name__ == "__main__":
print("start")
try:
with time_limit(10):
a=1
while True:
a = -a
except RuntimeError:
print("timed out")
print("finished")
Different ways of debugging will give different results:
-
Use Pause. The exception is not caught. I click the
pause (F6)halfway through running, and the program pauses on the linea=-aas expected. After several seconds, the time limit is reached, and the RuntimeError is thrown, but the program fails to catch the error. The trackback is printed in the console, but the program is not interrupted (still paused). As a result, the program will run forever after clickingcontinue (F5). -
Use preset breakpoint. The exception is caught. In contrast, if you set a breakpoint at the
a=-a. Run the program, and the program will stop at the breakpoint. Wait a few seconds, and the program will catch the runtime error and finish successfully. The program will continue automatically once it receives the Exception without the user's permission, which is also strange to me. -
Add a breakpoint halfway. The exception is not caught. If you add a new breakpoint at
a=-aafter the program runs for a while, you can find the same behavior as "using Pause". In my opinion, "Pause" may be implemented by "adding a breakpoint halfway"? If this is correct, then this problem may be about "adding a breakpoint while running".
More experimental results:
When using Pause. After pausing, if I switch to the Debug Console, the following message will be thrown when the time limit is reached:
<class 'RuntimeError'> raised from within the callback set in sys.settrace.
Debugging will be disabled for this thread (<_MainThread(MainThread, started 140324903388352)>).
Expected behavior
I expect both 1(Use Pause) and 3(Add a breakpoint halfway) to behave similarly to 2(Use preset breakpoint).
Steps to reproduce:
- As stated in Actual behavior, just try to debug the code in three different ways.
- 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ự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
stephrobert/dsoxlab#238 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
sublimehq/package_control#1780 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
nwg-piotr/nwg-displays#145 ·