mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 13:52:54 +00: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:
@@ -163,7 +163,7 @@ class ResultProcess(multiprocessing.Process):
|
||||
|
||||
except queue.Empty:
|
||||
pass
|
||||
except (KeyboardInterrupt, IOError, EOFError):
|
||||
except (KeyboardInterrupt, SystemExit, IOError, EOFError):
|
||||
break
|
||||
except:
|
||||
# TODO: we should probably send a proper callback here instead of
|
||||
|
||||
@@ -132,7 +132,7 @@ class WorkerProcess(multiprocessing.Process):
|
||||
self._rslt_q.put(task_result, block=False)
|
||||
|
||||
except Exception as e:
|
||||
if not isinstance(e, (IOError, EOFError, KeyboardInterrupt)) or isinstance(e, TemplateNotFound):
|
||||
if not isinstance(e, (IOError, EOFError, KeyboardInterrupt, SystemExit)) or isinstance(e, TemplateNotFound):
|
||||
try:
|
||||
self._host.vars = dict()
|
||||
self._host.groups = []
|
||||
@@ -140,7 +140,7 @@ class WorkerProcess(multiprocessing.Process):
|
||||
self._rslt_q.put(task_result, block=False)
|
||||
except:
|
||||
debug(u"WORKER EXCEPTION: %s" % to_unicode(e))
|
||||
debug(u"WORKER EXCEPTION: %s" % to_unicode(traceback.format_exc()))
|
||||
debug(u"WORKER TRACEBACK: %s" % to_unicode(traceback.format_exc()))
|
||||
|
||||
debug("WORKER PROCESS EXITING")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user