From f33a59624143a8bb44620ae2e1bbc1e374d517ce Mon Sep 17 00:00:00 2001 From: Nishith Vihar Sakinala Date: Tue, 27 Apr 2021 18:00:15 +0530 Subject: [PATCH 1/2] Signal Handler is added Signal handler is added for the graceful exit of the test framework. Fixes: #208 Signed-off-by: Nishith Vihar Sakinala --- core/redant_main.py | 7 +++++++ core/signal_handler.py | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 core/signal_handler.py diff --git a/core/redant_main.py b/core/redant_main.py index 0993454e8..20e87ba70 100644 --- a/core/redant_main.py +++ b/core/redant_main.py @@ -4,10 +4,13 @@ 2) Tests-to-run list preparation (by test_list_builder). 3) Invocation of the test_runner. """ + +import signal import sys import time import datetime import argparse +from signal_handler import signal_handler from parsing.params_handler import ParamsHandler from test_list_builder import TestListBuilder from test_runner import TestRunner @@ -104,4 +107,8 @@ def main(): if __name__ == '__main__': + + signal.signal(signal.SIGINT, signal_handler) + signal.signal(signal.SIGTSTP, signal_handler) + main() diff --git a/core/signal_handler.py b/core/signal_handler.py new file mode 100644 index 000000000..c7f7fac31 --- /dev/null +++ b/core/signal_handler.py @@ -0,0 +1,18 @@ +""" +This file consists of functions for handling +signals. Signal handling is required for the +graceful exit of the test framework +""" + +def signal_handler(signalNumber, frame): + """ + Function for handling signal and raising the + SystemExit call for graceful exit of the test + framework + Args: + signalNumber (int): The signal number of the signal caught + frame: current stack frame, None or stack frame object. + """ + print("Signal Received",signalNumber) + raise SystemExit('Exiting...') + return From 04a9ee5b60715b7d2004e0dd23936e8c458a7aed Mon Sep 17 00:00:00 2001 From: Nishith Vihar Sakinala Date: Tue, 11 May 2021 11:09:55 +0530 Subject: [PATCH 2/2] Flake fix Updates: #58 Signed-off-by: Nishith Vihar Sakinala --- core/redant_main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/redant_main.py b/core/redant_main.py index 20e87ba70..d83541c66 100644 --- a/core/redant_main.py +++ b/core/redant_main.py @@ -110,5 +110,5 @@ def main(): signal.signal(signal.SIGINT, signal_handler) signal.signal(signal.SIGTSTP, signal_handler) - + main()