From 6afcbb3ca54bf5242ba8a88f6bbc8b3bb7611e4c Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sat, 12 Mar 2022 17:02:26 +0500 Subject: server.py: minor refactoring --- server.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'server.py') diff --git a/server.py b/server.py index 9fa7530..c0b8fc5 100755 --- a/server.py +++ b/server.py @@ -59,6 +59,11 @@ def handle_sigterm(signum, frame): set_exiting() +def handle_sigint(): + print('\nKeyboard interrupt received, exiting...') + set_exiting() + + @contextmanager def setup_signal_handlers(httpd): handler_thread = SignalHandler(httpd) @@ -119,8 +124,7 @@ def main(args=None): try: httpd.serve_forever() except KeyboardInterrupt: - print('\nKeyboard interrupt received, exiting...') - set_exiting() + handle_sigint() if __name__ == '__main__': -- cgit v1.2.3