Skip to content

Commit

Permalink
Don't print full KeyboardInterrupt Exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
jankatins committed Jul 2, 2020
1 parent 9a6b816 commit 90a6cce
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
5 changes: 4 additions & 1 deletion mara_pipelines/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions mara_pipelines/logging/system_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit 90a6cce

Please sign in to comment.