Skip to content

_signals.terminator_handler: ensure exit finally

It's possible for the custom termination handlers to raise exceptions. Indeed this was actually the case for utils._call(). They're especially difficult to reach with tests, so make extra effort to insulate them.

Ensure the os._exit(-1) always happens by placing it in a finally clause by itself. Otherwise the program will continue to execute, ignoring the SIGTERM and having executed some part of the handlers.

Print any exceptions encountered as a regular traceback before exiting - the os._exit() will prevent the default exception printing.

Merge request reports