From 872d631274e0e5573999a4401f945cb19976d428 Mon Sep 17 00:00:00 2001 From: nogjam Date: Thu, 23 Jan 2025 11:04:10 -0800 Subject: [PATCH] Silence multiprocessing KeyboardInterrupt traceback Previously when sending SIGINT to the server process, we would get tons of traceback output. This resolves #2065. --- strictdoc/helpers/parallelizer.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/strictdoc/helpers/parallelizer.py b/strictdoc/helpers/parallelizer.py index c928a35a0..68e643854 100644 --- a/strictdoc/helpers/parallelizer.py +++ b/strictdoc/helpers/parallelizer.py @@ -116,11 +116,15 @@ def _run( output_queue: "multiprocessing.Queue[Tuple[int, Any]]", ) -> None: while True: - content_idx, content, processing_func = input_queue.get(block=True) - result = processing_func(content) - sys.stdout.flush() - sys.stderr.flush() - output_queue.put((content_idx, result)) + try: + content_idx, content, processing_func = input_queue.get(block=True) + result = processing_func(content) + sys.stdout.flush() + sys.stderr.flush() + output_queue.put((content_idx, result)) + except KeyboardInterrupt: + sys.stdout.flush() + sys.stderr.flush() class NullParallelizer(Parallelizer):