From e23af21b2150d3b5e1cb51d31dbf2fb05ad34ec5 Mon Sep 17 00:00:00 2001 From: Steven Penny Date: Tue, 14 Jan 2020 22:41:38 -0600 Subject: [PATCH] listen: handle KeyboardInterrupt Current response to Ctrl+C with "pelican --listen" is to bail with an exception. Instead, exit proper and show a message. Fixes #2676 --- pelican/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pelican/__init__.py b/pelican/__init__.py index 17f4f922..d3889b26 100644 --- a/pelican/__init__.py +++ b/pelican/__init__.py @@ -474,6 +474,9 @@ def listen(server, port, output, excqueue=None): excqueue.put(traceback.format_exception_only(type(e), e)[-1]) return + except KeyboardInterrupt: + logger.info("Shutting down server.") + httpd.socket.close() def main(argv=None): args = parse_arguments(argv)