Skip to content

Commit 592dfae

Browse files
committed
Signal Handler is added
Signal handler is added for the graceful exit of the test framework. Fixes: #208 Signed-off-by: Nishith Vihar Sakinala <[email protected]>
1 parent e1e320f commit 592dfae

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

core/redant_main.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
3) Invocation of the test_runner.
66
"""
77

8+
import signal
89
import sys
910
import time
1011
import datetime
1112
import argparse
13+
from signal_handler import signal_handler
1214
from parsing.params_handler import ParamsHandler
1315
from test_list_builder import TestListBuilder
1416
from test_runner import TestRunner
@@ -94,4 +96,8 @@ def main():
9496

9597

9698
if __name__ == '__main__':
99+
100+
signal.signal(signal.SIGINT, signal_handler)
101+
signal.signal(signal.SIGTSTP, signal_handler)
102+
97103
main()

core/signal_handler.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"""
2+
This file consists of functions for handling
3+
signals. Signal handling is required for the
4+
graceful exit of the test framework
5+
"""
6+
7+
def signal_handler(signalNumber, frame):
8+
"""
9+
Function for handling signal and raising the
10+
SystemExit call for graceful exit of the test
11+
framework
12+
Args:
13+
signalNumber (int): The signal number of the signal caught
14+
frame: current stack frame, None or stack frame object.
15+
"""
16+
print("Signal Received",signalNumber)
17+
raise SystemExit('Exiting...')
18+
return

0 commit comments

Comments
 (0)