pydnstest/testserver: handle SIGTERM, SIGINT gracefully

parent 569ffd56
...@@ -4,8 +4,10 @@ import argparse ...@@ -4,8 +4,10 @@ import argparse
import itertools import itertools
import logging import logging
import os import os
import signal
import select import select
import socket import socket
import sys
import threading import threading
import time import time
...@@ -256,13 +258,17 @@ def standalone_self_test(): ...@@ -256,13 +258,17 @@ def standalone_self_test():
server.start() server.start()"[==========] Mirror server running at %s", server.address())"[==========] Mirror server running at %s", server.address())
while True: def exit(signum, frame):
except KeyboardInterrupt:"[==========] Shutdown.")"[==========] Shutdown.")
pass server.stop()
server.stop() sys.exit(128 + signum)
signal.signal(signal.SIGINT, exit)
signal.signal(signal.SIGTERM, exit)
while True:
if __name__ == '__main__': if __name__ == '__main__':
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment