diff --git a/mara_pipelines/execution.py b/mara_pipelines/execution.py index 60a4a32..2187ed1 100644 --- a/mara_pipelines/execution.py +++ b/mara_pipelines/execution.py @@ -378,7 +378,10 @@ def _create_exception_output_event(msg: str = None): # At least try to notify the UI for e in exception_events: - print(f"{repr(e)}", file=sys.stderr) + if isinstance(e, KeyboardInterrupt): + print(f"Interrupted", file=sys.stderr) + else: + print(f"{repr(e)}", file=sys.stderr) yield e events.notify_configured_event_handlers(e) # try to terminate the run_process which itself will also cleanup in an atexit handler diff --git a/mara_pipelines/logging/system_statistics.py b/mara_pipelines/logging/system_statistics.py index 485c4fb..5e5d2f3 100644 --- a/mara_pipelines/logging/system_statistics.py +++ b/mara_pipelines/logging/system_statistics.py @@ -83,7 +83,10 @@ def __getattr__(self, item): return 0 discs_last = psutil.disk_io_counters() or zero nets_last = psutil.net_io_counters() or zero mb = 1024 * 1024 - time.sleep(period) + try: + time.sleep(period) + except KeyboardInterrupt: + return while True: discs_cur = psutil.disk_io_counters() or zero nets_cur = psutil.net_io_counters() or zero @@ -101,5 +104,7 @@ def __getattr__(self, item): return 0 n += 1 if n % 100 == 0: period *= 2 - - time.sleep(period) + try: + time.sleep(period) + except KeyboardInterrupt: + break