Skip to content

Commit

Permalink
Merge pull request #1362 from missionpinball/update_asciimatics
Browse files Browse the repository at this point in the history
Update asciimatics
  • Loading branch information
jabdoa2 committed May 10, 2019
2 parents 4a1c844 + f6a8266 commit 69de752
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 133 deletions.
17 changes: 11 additions & 6 deletions mpf/core/machine.py
Expand Up @@ -754,13 +754,14 @@ def _do_stop(self) -> None:

def _crash_shutdown(self):
"""MPF crashed. Cleanup as good as we can."""
# call crash handlers
for handler in self._crash_handlers:
handler()
if hasattr(self, "events") and hasattr(self, "clock"):
# if we already got events and a clock use normal shutdown
self._do_stop()
else:
# call crash handlers
for handler in self._crash_handlers:
handler()
# otherwise just shutdown
self.shutdown()

def shutdown(self) -> None:
Expand Down Expand Up @@ -789,12 +790,16 @@ def _run_loop(self) -> None: # pragma: no cover
self.log.exception("Loop exited with exception")
return

self._do_stop()

if self._exception:
self._crash_shutdown()

print("Shutdown because of an exception:")
raise self._exception['exception']
try:
raise self._exception['exception']
except: # noqa
self.log.exception("Runtime Exception")
else:
self._do_stop()
print("Shutdown reason: {}".format(reason))

def _platform_stop(self) -> None:
Expand Down

0 comments on commit 69de752

Please sign in to comment.