From b0d986a5ec7fbe79cfe34c7af75695da10fc5ffe Mon Sep 17 00:00:00 2001 From: Jeremy Leibs Date: Thu, 20 Apr 2023 02:58:57 -0400 Subject: [PATCH] More robust wait for exit condition during .serve() (#1939) * More robust wait for exit condition during .serve() * lint --- rerun_py/rerun_sdk/rerun/script_helpers.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/rerun_py/rerun_sdk/rerun/script_helpers.py b/rerun_py/rerun_sdk/rerun/script_helpers.py index 8b59133dd090..3504d9d74593 100644 --- a/rerun_py/rerun_sdk/rerun/script_helpers.py +++ b/rerun_py/rerun_sdk/rerun/script_helpers.py @@ -91,10 +91,10 @@ def script_teardown(args: Namespace) -> None: """ if args.serve: - import signal - from threading import Event + import time - exit = Event() - signal.signal(signal.SIGINT, lambda sig, frame: exit.set()) - print("Sleeping while serving the web viewer. Abort with Ctrl-C") - exit.wait() + try: + while True: + time.sleep(1) + except KeyboardInterrupt: + print("Ctrl-C received. Exiting.")