Process creation after debugging session not possible: teardown needed
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 70/100
Hướng nghiên cứu
Bắt đầu tại debugpy._vendored.pydevd.pydevd ở stoptrace() và kiểm tra cách patch_new_process_functions() thay thế _winapi.CreateProcess. Tái hiện sự cố bằng ví dụ subprocess.Popen được cung cấp sau teardown, sau đó xác minh rằng việc tạo tiến trình hoạt động trở lại sau teardown mà không cần khởi động lại chương trình.
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: latest
- OS and version: Windows 11
- Python version 314 (but issue is not python-version related)
- Using VS Code
Actual behavior
Connect to VSCode. Then apply
test = subprocess.Popen(
["C:\Python314\python.exe", "-c", "import sys; sys.exit(0)"],
creationflags=creationflags,
)
test.wait()
print(test.returncode)
this does not work because subprocess was patched. Also not after teardown of the debugging session:
from debugpy._vendored.pydevd.pydevd import stoptrace
stoptrace() to continue running the process. Now, subprocess.popen() does not work any more at al.
.... still subprocess.Popen will not work
Expected behavior
subprocess.Popen() should work
Steps to reproduce:
After debugging started, the following won't work. Make sure NOT to issue
debugpy.configure(subProcess=False) in order to reproduce this:
test = subprocess.Popen(
["C:\Python314\python.exe", "-c", "import sys; sys.exit(0)"],
creationflags=creationflags,
)
test.wait()
print(test.returncode)
SOLUTION
pydevd's patch_new_process_functions() patches _winapi.CreateProcess to intercept child process creation for subprocess debugging, but stoptrace() never unpatches it.
The effect is that you can't spawn processes after a debugging session is torn down and you want to resume your program without restart. The solution is a restoration on teardown:
from debugpy._vendored.pydevd.pydevd import stoptrace
stoptrace()
debugpy.server.api.listen.called = False # reset state so it can reconnect later
try:
import _winapi as _subprocess
except ImportError:
import _subprocess
if hasattr(_subprocess, 'original_CreateProcess'):
_subprocess.CreateProcess = _subprocess.original_CreateProcess
del _subprocess.original_CreateProcess
- 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 ·