Fix shutdown should be called after python code detected KeyboardInterrupt exception

This commit is contained in:
allegroai 2021-04-15 00:06:53 +03:00
parent 59d531d1c8
commit 91d63df488

View File

@ -3125,6 +3125,11 @@ class Task(_Task):
org_handler = self._org_handlers.get(sig)
signal.signal(sig, org_handler or signal.SIG_DFL)
# if this is a sig term, we wait until __at_exit is called (basically do nothing)
if sig == signal.SIGINT:
# return original handler result
return org_handler if not callable(org_handler) else org_handler(sig, frame)
if self._signal_recursion_protection_flag:
# call original
os.kill(os.getpid(), sig)