From 7f1ecdec8b88b9e0efa9bfa7b127862c4a2e85d5 Mon Sep 17 00:00:00 2001 From: Marcus Desai Date: Tue, 25 Jul 2023 20:27:40 +0100 Subject: [PATCH] Fixes #3163; cleanup child processes on kill --- pelican/__init__.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/pelican/__init__.py b/pelican/__init__.py index 9858dbd3..bd867988 100644 --- a/pelican/__init__.py +++ b/pelican/__init__.py @@ -543,13 +543,15 @@ def main(argv=None): target=listen, args=(settings.get('BIND'), settings.get('PORT'), settings.get("OUTPUT_PATH"), excqueue)) - p1.start() - p2.start() - exc = excqueue.get() - p1.terminate() - p2.terminate() - if exc is not None: - logger.critical(exc) + try: + p1.start() + p2.start() + exc = excqueue.get() + if exc is not None: + logger.critical(exc) + finally: + p1.terminate() + p2.terminate() elif args.autoreload: autoreload(args) elif args.listen: