diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2022-03-12 17:02:26 +0500 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2022-03-12 17:02:26 +0500 |
commit | 6afcbb3ca54bf5242ba8a88f6bbc8b3bb7611e4c (patch) | |
tree | 43b30aac9f3d5c5fcc4acfa5d7c3d021579727f8 | |
parent | README: update (diff) | |
download | void-6afcbb3ca54bf5242ba8a88f6bbc8b3bb7611e4c.tar.gz void-6afcbb3ca54bf5242ba8a88f6bbc8b3bb7611e4c.zip |
server.py: minor refactoring
-rwxr-xr-x | server.py | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -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__': |