Skip to content
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

Add configuration option to issue a SIGTERM (or other signal) when the debugger is being stopped #1818

Open
DeflateAwning opened this issue Jan 27, 2025 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@DeflateAwning
Copy link

DeflateAwning commented Jan 27, 2025

Related to implementing this issue: microsoft/vscode-python-debugger#316

Example Use Cases

  • When working with hardware, hardware connections/locks can be released.
  • Debugging/testing signal handling capabilities (e.g., testing an AWS Batch container termination)

Related Issues

@1st
Copy link

1st commented Feb 3, 2025

Totally support this. My use case:

  • run a debugger for Python async code
  • then stop debugger by pressing a red square

Expected:

  • code will be stopped in the same way as when I click Ctrl+C
  • in my code I can use except asyncio.CancelledError as e: to catch this exception on the needed level and exit my program gratefully. I do not do it for Ctrl + C and it works well for me
  • when I stop my code gratefully, I can close WebSocket, DB and other opened connections. It will avoid problems with unclosed network connections and file descriptors

Actual:

  • when I stop debugger using red square, it kills the process
  • any signals like these aren't raised by debugger: signal.signal(signal.SIGINT, signal_handler) or signal.signal(signal.SIGTERM, signal_handler)

Workaround:

  • as for now, we can go to the terminal with debugger and press there Ctrl + C. It will stop debugger in a needed way

I would like to see an option in the launch.json file that allows to control how debugger is existed - by killing the process or by sending a signal. Sending a signal is a preferred way as it allows to handle program exit in a predefined way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants