Skip to content

Commit

Permalink
Silence multiprocessing KeyboardInterrupt traceback
Browse files Browse the repository at this point in the history
Previously when sending SIGINT to the server process, we would get tons
of traceback output. This resolves #2065.
  • Loading branch information
nogjam committed Jan 23, 2025
1 parent c029583 commit 872d631
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions strictdoc/helpers/parallelizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 872d631

Please sign in to comment.