python / cpython

The Python programming language
https://www.python.org
Other
63.53k stars 30.43k forks source link

Handle SIGTERM in asyncio #125688

Closed PSanetra closed 3 weeks ago

PSanetra commented 1 month ago

Feature or enhancement

Proposal:

32105 did introduce handling of SIGINT signals in asyncio.run(). I think it makes sense to support handling of SIGTERM signals in the same way as both signals are intended for shutting down a process gracefully. SIGTERM is also the default signal to stop a container: https://docs.docker.com/reference/cli/docker/container/stop/

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

ZeroIntensity commented 1 month ago

cc @graingert, you're better at dealing with asyncio stuff than I am.

graingert commented 1 month ago

cpython doesn't define a handler for SIGTERM for synchronous code, so I don't think asyncio should either

ZeroIntensity commented 1 month ago

@PSanetra, I'm going to suggest taking this to DPO. If it's not clear that something is a no-brainer, it generally has to get discussed there.

graingert commented 3 weeks ago

Let's close this for now