From 8fc0c95332a70a1c71c1c42a588fac2b85ff3f7e Mon Sep 17 00:00:00 2001 From: Adrien Berchet Date: Thu, 5 Dec 2024 11:42:10 +0100 Subject: [PATCH] Handle KeyboardInterrupt during sleep --- diff_pdf_visually/diff.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/diff_pdf_visually/diff.py b/diff_pdf_visually/diff.py index a6f07de..92ee756 100644 --- a/diff_pdf_visually/diff.py +++ b/diff_pdf_visually/diff.py @@ -236,13 +236,16 @@ def pdfdiff_pages( if time_to_inspect > 0: print( - "Waiting for {} seconds before removing temporary directory...".format( + "Waiting for {} seconds (or Ctrl+C) before removing temporary directory...".format( time_to_inspect ), end="", flush=True, ) - time.sleep(time_to_inspect) + try: + time.sleep(time_to_inspect) + except KeyboardInterrupt: + pass print(" done.") return list(map(lambda pair: pair[1], largest_significances))