Install SIGINT/TERM handler for backtrace-free CTRL-C
This just avoids dumping a trace in case of CTRL-C. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
parent
94555bb892
commit
e9feb07567
@ -75,6 +75,13 @@ def create_logger():
|
|||||||
return logging.getLogger(__name__)
|
return logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
def interruption():
|
||||||
|
"""
|
||||||
|
Handle SIGINT/SIGTERM
|
||||||
|
"""
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def _atexit_handler(loop):
|
def _atexit_handler(loop):
|
||||||
"""
|
"""
|
||||||
Close event loop and terminate the whole process group
|
Close event loop and terminate the whole process group
|
||||||
@ -112,6 +119,8 @@ def kas(argv):
|
|||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
|
|
||||||
|
for sig in (signal.SIGINT, signal.SIGTERM):
|
||||||
|
loop.add_signal_handler(sig, interruption)
|
||||||
atexit.register(_atexit_handler, loop=loop)
|
atexit.register(_atexit_handler, loop=loop)
|
||||||
|
|
||||||
for cmd in sub_cmds:
|
for cmd in sub_cmds:
|
||||||
|
Loading…
Reference in New Issue
Block a user