microsoft / vscode-python-debugger

Python debugger (debugpy) extension for VS Code.
https://marketplace.visualstudio.com/items?itemName=ms-python.debugpy
MIT License
41 stars 17 forks source link

Add configuration option to issue a SIGTERM when the Stop button is clicked in debugger #316

Open DeflateAwning opened 2 months ago

DeflateAwning commented 2 months ago

I want the ability to use the "Stop" button in the Python debugger in VS Code to send a SIGTERM (and/or maybe a SIGINT) to the running process, instead of just sending it SIGKILL (as it currently does).

This is the "Stop" button I'm talking about: image

Proposed Solution

I'm thinking that a new option like this in the launch.json config file could be a good way to introduce this change without being a breaking change for the way everyone is used to the "stop" button working.

{
  "configurations": [
    {
      "name": "Python Debugger: Current File (Integrated Terminal)",
      "type": "debugpy",
      "request": "launch",
      "program": "${file}",
      "console": "integratedTerminal",
      "stop_action": "SIGKILL", // this would be a new enum-like config option, with values of "SIGKILL", "SIGINT", "SIGTERM", maybe others
    },
  ]
}

Possible additional ideas, more context

Under the hood, the Amazon ECS StopTask API call is used, which sends a SIGTERM value to the running container task. If after 30 seconds the container is still running, a SIGKILL signal is sent to forcibly stop the container. If the container handles the SIGTERM value gracefully and exits within 30 seconds from receiving it, no SIGKILL value is sent.

Related Previous Issues and Discussions

paulacamargo25 commented 1 month ago

Thanks for the feature request! We are going to give the community 60 days to provide 7 👍 upvotes on the opening comment to gauge general interest in this idea. If there's enough upvotes then we will consider this feature request in our future planning. If there's unfortunately not enough upvotes then we will close this issue.

cdelacruzpinto commented 1 week ago

Any intention to retake this? would be super useful to debug actions running on flask/fastapi app shutdown (i.e: closing db, connections, redis, etc)