aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Sommerseth <davids@redhat.com>2012-12-18 15:40:57 +0100
committerDavid Sommerseth <davids@redhat.com>2012-12-18 15:40:57 +0100
commitd3976bd04b251dfdb6a2823326acbdfbfa57c1e6 (patch)
treede4314ff4b55587f9aa495870c0fd804768047a3
parent659cb94488cb852165f31810c20ad8bbdb9bd5e4 (diff)
downloadrteval-d3976bd04b251dfdb6a2823326acbdfbfa57c1e6.tar.gz
Merge signal handlers into a single function
Signed-off-by: David Sommerseth <davids@redhat.com>
-rw-r--r--rteval/__init__.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/rteval/__init__.py b/rteval/__init__.py
index a7cc301..80cd5f9 100644
--- a/rteval/__init__.py
+++ b/rteval/__init__.py
@@ -46,15 +46,14 @@ import rtevalConfig, rtevalMailer
RTEVAL_VERSION = "2.0_pre"
sigint_received = False
-def sigint_handler(signum, frame):
- global sigint_received
- sigint_received = True
- print "*** SIGINT received - stopping rteval run ***"
+def sig_handler(signum, frame):
-
-
-def sigterm_handler(signum, frame):
- raise RuntimeError, "SIGTERM received!"
+ if signum == signal.SIGINT:
+ global sigint_received
+ sigint_received = True
+ print "*** SIGINT received - stopping rteval run ***"
+ elif signum == signal.SIGTERM:
+ raise RuntimeError("SIGTERM received!")
@@ -194,8 +193,8 @@ class RtEval(rtevalReport):
measure_start = datetime.now()
# wait for time to expire or thread to die
- signal.signal(signal.SIGINT, sigint_handler)
- signal.signal(signal.SIGTERM, sigterm_handler)
+ signal.signal(signal.SIGINT, sig_handler)
+ signal.signal(signal.SIGTERM, sig_handler)
self.__logger.log(Log.INFO, "waiting for duration (%f)" % self.__rtevcfg.duration)
stoptime = (time.time() + self.__rtevcfg.duration)
currtime = time.time()