Convert SIGTERM to an exception by default?

Yup, that’s about it. You still couldn’t absolutely rely on __exit__() methods or finally: blocks getting run - someone could use SIGKILL to kill your process, or the power could fail. But for normal ‘stop this service’ cases your code would get to clean up temp files, shut down communications channels nicely, and so on.

There are better ways to do it in application code, but I don’t think there’s a better option that Python could do by default. The better ways rely on knowing about the application - e.g. what event loop it’s using, what tasks it could be running.

I think the exception would be a better default than insta-killing the process - it seems to work well enough for SIGINT (Ctrl-C). But a half-sensible default would probably make people less likely to set up a signal handler themselves. There are people who seem to be strongly against making a change, and I don’t feel strongly enough to fight for it.