termination handling

- moved to base cli class to handle centrally and duplicate less code
- now avoids duplication and reiteration of signal handler by reassigning it
- left note on how to do non-graceful in case we add in future
  as I won't remember everything i did here and don't want to 'relearn' it.
This commit is contained in:
Brian Coca 2016-02-10 09:48:05 -05:00
commit 38120c1075
3 changed files with 19 additions and 22 deletions

View file

@ -19,11 +19,7 @@
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import getpass
import locale
import os
import signal
import sys
from ansible.compat.six import string_types
@ -32,8 +28,6 @@ from ansible.executor.task_queue_manager import TaskQueueManager
from ansible.playbook import Playbook
from ansible.template import Templar
from ansible.utils.unicode import to_unicode
try:
from __main__ import display
except ImportError:
@ -69,8 +63,6 @@ class PlaybookExecutor:
may limit the runs to serialized groups, etc.
'''
signal.signal(signal.SIGTERM, self._terminate)
result = 0
entrylist = []
entry = {}
@ -207,10 +199,6 @@ class PlaybookExecutor:
return result
def _terminate(self, signum=None, framenum=None):
display.debug("Termination signal detected, shutting down gracefully")
raise SystemExit
def _get_serialized_batches(self, play):
'''
Returns a list of hosts, subdivided into batches based on