Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to make program stop only when exceptions are raised? #1793

Closed
natsu1375 opened this issue Dec 29, 2024 · 1 comment
Closed

How to make program stop only when exceptions are raised? #1793

natsu1375 opened this issue Dec 29, 2024 · 1 comment
Assignees
Labels
needs repro Issue has not been reproduced yet

Comments

@natsu1375
Copy link

natsu1375 commented Dec 29, 2024

If run debugpy with --wait-for-client, the program stops and wait for connection. After client's connection, breakpoint() makes program stop, and also raised exceptions if Raised Exceptions is checked in VSCode.

But in my use cases, I don't want to use --wait-for-client as it stops the whole thing. I just want to debug the program if something goes wrong, such as assertions failed. If nothing goes wrong, the program proceeds normally to the end.

For example, this program

# foo.py
x=1
assert x==0
x=2

Run it with python -m debugpy --listen 1234 foo.py. The program did not stop at assert x==0, but this uncaught exception make it exit.

@github-actions github-actions bot added the needs repro Issue has not been reproduced yet label Dec 29, 2024
@rchiodo
Copy link
Contributor

rchiodo commented Jan 6, 2025

Sorry but what you're asking for isn't currently possible. A debugger must be attached in order to stop on exceptions. There's no way to launch a debugger after the program has already thrown the exception.

Theoretically the idea is possible though. You wouldn't use debugpy though, but something smaller that just listened to exception events and then possibly stopped the program and called out to VS code to attach.

I'll transfer this to a discussion item.

@rchiodo rchiodo closed this as completed Jan 6, 2025
@microsoft microsoft locked and limited conversation to collaborators Jan 6, 2025
@rchiodo rchiodo converted this issue into discussion #1796 Jan 6, 2025

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
needs repro Issue has not been reproduced yet
Projects
None yet
Development

No branches or pull requests

3 participants