microsoft / microsoft/vscode-python-debugger
Prevent vscode from exiting the Python interpreter a script completes
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- TypeScript
- Star
- 181
- Fork
- 126
- Merge trung bình
- 2 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 3
Mô tả
Discussed in https://github.com/microsoft/vscode-python/discussions/16082
Originally posted by larsoner April 29, 2021
The way I have used Python for years (through Spyder, directly from a bash terminal, etc.) is to execute a script in interactive mode such that once it's done, you can interact with it, e.g.:
python -i script.py
VSCode's debugger does not give a way to get this behavior currently. And it seems like I am not the only one looking for it:
- https://stackoverflow.com/questions/56568304/how-to-run-my-python-module-in-visual-studio-code-in-interactive-mode
- https://stackoverflow.com/questions/54609806/how-to-prevent-vscode-from-exiting-python-environment-after-running-code
- https://www.reddit.com/r/vscode/comments/8uv8xc/how_to_keep_python_running_after_script_execution/
- https://github.com/microsoft/vscode-python/issues/5497
One workaround is to put a breakpoint at the end of your file, but this requires extra work.
Another workaround is to add "env": {"PYTHONINSPECT": "true"}, to the launch configuration with integratedTerminal, but this doesn't work properly as any input is captured and newlines aren't treated properly while printing, which makes it pretty unusable.
I could see at least two potential solutions (the first would be better I think):
- Make it so that in
PYTHONINSPECTmode, the terminal could be interacted with properly, possibly by adding a newinspectOnExitor something that ran in-i/PYTHONINSPECTmode and returned proper input/output when the script completes. Based on https://github.com/microsoft/vscode-python/issues/5497 it sounds like this is a no-go, though. - Add a
stopOnExitdebug option to mirrorstopOnEntryin the debugger. This way at least variables could be inspected using the vscode debugger.
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.
Hướng nghiên cứu
Issue không nêu tên tệp triển khai hoặc kiểm thử nào. Hãy bắt đầu bằng việc xem lại cuộc thảo luận được liên kết và hành vi hiện có của trình gỡ lỗi stopOnEntry, sau đó so sánh các cách tiếp cận tương tác PYTHONINSPECT và stopOnExit được đề xuất với issue 5497. Done cần cung cấp trải nghiệm kiểm tra sau tập lệnh có thể sử dụng được mà không yêu cầu breakpoint ở cuối.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- typescript
- Lĩnh vực
- devtools
- Loại issue
- Tính năng
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 25/100