diff options
-rw-r--r-- | src/lib/Bcfg2/Server/Core.py | 17 | ||||
-rwxr-xr-x | src/sbin/bcfg2-test | 15 | ||||
-rwxr-xr-x | tools/bcfg2-profile-templates.py | 15 |
3 files changed, 13 insertions, 34 deletions
diff --git a/src/lib/Bcfg2/Server/Core.py b/src/lib/Bcfg2/Server/Core.py index 782aafbf1..6f642e347 100644 --- a/src/lib/Bcfg2/Server/Core.py +++ b/src/lib/Bcfg2/Server/Core.py @@ -2,13 +2,14 @@ implementations inherit from. """ import os -import atexit -import logging -import select import sys -import threading import time +import atexit +import select +import signal +import logging import inspect +import threading import lxml.etree import Bcfg2.settings import Bcfg2.Server @@ -285,6 +286,14 @@ class BaseCore(object): #: The CA that signed the server cert self.ca = setup['ca'] + def hdlr(sig, frame): # pylint: disable=W0613 + """ Handle SIGINT/Ctrl-C by shutting down the core and exiting + properly. """ + self.shutdown() + os._exit(1) # pylint: disable=W0212 + + signal.signal(signal.SIGINT, hdlr) + #: The FAM :class:`threading.Thread`, #: :func:`_file_monitor_thread` self.fam_thread = \ diff --git a/src/sbin/bcfg2-test b/src/sbin/bcfg2-test index f77e98269..8f9912139 100755 --- a/src/sbin/bcfg2-test +++ b/src/sbin/bcfg2-test @@ -5,7 +5,6 @@ without failures""" import os import sys -import signal import fnmatch import logging import Bcfg2.Logger @@ -73,19 +72,6 @@ class ClientTest(TestCase): id = __str__ -def get_sigint_handler(core): - """ Get a function that handles SIGINT/Ctrl-C by shutting down the - core and exiting properly.""" - - def hdlr(sig, frame): # pylint: disable=W0613 - """ Handle SIGINT/Ctrl-C by shutting down the core and exiting - properly. """ - core.shutdown() - os._exit(1) # pylint: disable=W0212 - - return hdlr - - def main(): optinfo = dict(noseopts=Bcfg2.Options.TEST_NOSEOPTS, test_ignore=Bcfg2.Options.TEST_IGNORE, @@ -113,7 +99,6 @@ def main(): setup['noseopts'].append("-v") core = Bcfg2.Server.Core.BaseCore(setup) - signal.signal(signal.SIGINT, get_sigint_handler(core)) ignore = dict() for entry in setup['test_ignore']: diff --git a/tools/bcfg2-profile-templates.py b/tools/bcfg2-profile-templates.py index cc7a1a3d8..3cd3786f9 100755 --- a/tools/bcfg2-profile-templates.py +++ b/tools/bcfg2-profile-templates.py @@ -4,7 +4,6 @@ import os import sys import time -import signal import logging import operator import Bcfg2.Logger @@ -13,19 +12,6 @@ import Bcfg2.Server.Core LOGGER = None -def get_sigint_handler(core): - """ Get a function that handles SIGINT/Ctrl-C by shutting down the - core and exiting properly.""" - - def hdlr(sig, frame): # pylint: disable=W0613 - """ Handle SIGINT/Ctrl-C by shutting down the core and exiting - properly. """ - core.shutdown() - os._exit(1) # pylint: disable=W0212 - - return hdlr - - def main(): optinfo = \ dict(client=Bcfg2.Options.Option("Benchmark templates for one client", @@ -53,7 +39,6 @@ def main(): logger = logging.getLogger(sys.argv[0]) core = Bcfg2.Server.Core.BaseCore(setup) - signal.signal(signal.SIGINT, get_sigint_handler(core)) logger.info("Bcfg2 server core loaded") core.fam.handle_events_in_interval(0.1) logger.debug("Repository events processed") |