Skip to content

Commit 1ea4202

Browse files
authored
Merge pull request #544 from simvue-io/hotfix/keyboard-interrupt-feedback
Handle KeyboardInterrupt and Exceptions
2 parents 10feb17 + af6e19b commit 1ea4202

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
## Unreleased
44

55
* Ensure all functionality is deactivated when mode is set to `disabled`.
6+
* When an exception is thrown an event is sent to Simvue displaying the traceback.
7+
* If `add_process` is used and an exception is thrown, `.err` and `.out` files are still uploaded.
68

79
## [v1.0.4](https://github.com/simvue-io/client/releases/tag/v1.0.4) - 2024-09-24
810

simvue/executor.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,8 @@ def kill_process(
414414
process.kill()
415415
process.wait()
416416

417+
self._save_output()
418+
417419
def kill_all(self) -> None:
418420
"""Kill all running processes"""
419421
for process in self._processes.keys():

simvue/run.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import pydantic
2121
import re
2222
import sys
23+
import traceback as tb
2324
import time
2425
import functools
2526
import platform
@@ -166,11 +167,19 @@ def _handle_exception_throw(
166167
if not _is_running:
167168
return
168169

169-
self.set_status("terminated" if _is_terminated else "failed")
170-
171170
if not self._active:
172171
return
173172

173+
_traceback_out: list[str] = tb.format_exception(exc_type, value, traceback)
174+
_event_msg: str = (
175+
"\n".join(_traceback_out)
176+
if _traceback_out
177+
else f"An exception was thrown: {_exception_thrown}"
178+
)
179+
180+
self.log_event(_event_msg)
181+
self.set_status("terminated" if _is_terminated else "failed")
182+
174183
# If the dispatcher has already been aborted then this will
175184
# fail so just continue without the event
176185
with contextlib.suppress(RuntimeError):
@@ -1415,7 +1424,8 @@ def _tidy_run(self) -> None:
14151424
if self._status == "running":
14161425
if self._dispatcher:
14171426
self._dispatcher.join()
1418-
self.set_status("completed")
1427+
if self._active:
1428+
self.set_status("completed")
14191429
elif self._dispatcher:
14201430
self._dispatcher.purge()
14211431
self._dispatcher.join()

0 commit comments

Comments
 (0)