Ignore SIGINT/TERM at kas level, let sub-processes handle it
This seems to be the cleanest and simplest way of properly terminating kas while one or more sub-processes are running: just ignore the signal. The sub-processes will get it as well, and they will terminate themselves properly. kas will get an error then and shut down. Problem solved. Forwarding the signal didn't work reliably anyway because we couldn't count on kas being a process group leader in all cases. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
parent
264be71ebe
commit
dd04836896
@ -83,18 +83,15 @@ def create_logger():
|
||||
|
||||
def interruption():
|
||||
"""
|
||||
Handle SIGINT/SIGTERM
|
||||
Ignore SIGINT/SIGTERM in kas, let them be handled by our sub-processes
|
||||
"""
|
||||
sys.exit(1)
|
||||
pass
|
||||
|
||||
|
||||
def _atexit_handler():
|
||||
"""
|
||||
Close event loop and terminate the whole process group
|
||||
Wait for completion of the event loop
|
||||
"""
|
||||
signal.signal(signal.SIGTERM, signal.SIG_IGN)
|
||||
os.killpg(os.getpid(), signal.SIGTERM)
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
pending = asyncio.Task.all_tasks()
|
||||
loop.run_until_complete(asyncio.gather(*pending))
|
||||
|
Loading…
Reference in New Issue
Block a user