mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-26 06:31:23 -07:00
correctly handle term signals
- adhoc now terminates gracefully - avoid race condition on terminations by ignoring errors if worker might have been reaped between checking if active and termination call - ansible-playbook now properly exits on sigint/term - adhoc and playbook now give exceptions that we should not normally capture and rely on top level finally to reap children - handle systemexit breaks in workers - added debug to see at which frame we exit partial fix for #14346
This commit is contained in:
parent
45755bc0e5
commit
5a1887cc76
5 changed files with 21 additions and 8 deletions
|
@ -69,7 +69,7 @@ class PlaybookExecutor:
|
|||
may limit the runs to serialized groups, etc.
|
||||
'''
|
||||
|
||||
signal.signal(signal.SIGINT, self._cleanup)
|
||||
signal.signal(signal.SIGTERM, self._terminate)
|
||||
|
||||
result = 0
|
||||
entrylist = []
|
||||
|
@ -199,7 +199,7 @@ class PlaybookExecutor:
|
|||
|
||||
finally:
|
||||
if self._tqm is not None:
|
||||
self._cleanup()
|
||||
self._tqm.cleanup()
|
||||
|
||||
if self._options.syntax:
|
||||
display.display("No issues encountered")
|
||||
|
@ -207,8 +207,9 @@ class PlaybookExecutor:
|
|||
|
||||
return result
|
||||
|
||||
def _cleanup(self, signum=None, framenum=None):
|
||||
return self._tqm.cleanup()
|
||||
def _terminate(self, signum=None, framenum=None):
|
||||
display.debug(framenum)
|
||||
raise SystemExit("Terminating run due to external signal")
|
||||
|
||||
def _get_serialized_batches(self, play):
|
||||
'''
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue