Skip to content

Commit

Permalink
Signal Handler is added
Browse files Browse the repository at this point in the history
Signal handler is added for the graceful exit of the
test framework.

Fixes: #208
Signed-off-by: Nishith Vihar Sakinala <nsakinal@redhat.com>
  • Loading branch information
nishith-vihar committed Apr 27, 2021
1 parent ca587b0 commit 0a9d462
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
8 changes: 7 additions & 1 deletion core/redant_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
from test_runner import TestRunner
from result_handler import ResultHandler
from environ import environ
from signal_handler import signal_handler
import signal

def pars_args():
"""
Expand Down Expand Up @@ -58,7 +60,7 @@ def main():

start = time.time()
args = pars_args()

ParamsHandler.set_config_hashmap(args.config_file)

# Obtain the client and server dict.
Expand Down Expand Up @@ -97,4 +99,8 @@ def main():


if __name__ == '__main__':

signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTSTP, signal_handler)

main()
20 changes: 20 additions & 0 deletions core/signal_handler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""
This file consists of functions for handling
signals. Signal handling is required for the
graceful exit of the test framework
"""

import signal

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

0 comments on commit 0a9d462

Please sign in to comment.