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 30, 2021
1 parent e1e320f commit 592dfae
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/redant_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
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
Expand Down Expand Up @@ -94,4 +96,8 @@ def main():


if __name__ == '__main__':

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

main()
18 changes: 18 additions & 0 deletions core/signal_handler.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 592dfae

Please sign in to comment.