Skip to content

Commit

Permalink
Catch exceptions in user provided stop() method
Browse files Browse the repository at this point in the history
==== Fixed Issues ====
#960

====  Tech Notes ====
The messagebus handler for "mycroft.stop" halts and exits if an
exception occurs in any methods that are registered to that name. The
handler executes the stop() method that's provided by the user and is
not verified. To ensure that other skills are unaffected exceptions in
the user provided method are caught.

====  Documentation Notes ====
NONE - things like description of a new feature or notes on behavior
changes

==== Localization Notes ====
NONE - point out new strings, functions needing international versions,
etc.

==== Environment Notes ====
NONE - new package requirements, new files being written to disk,
etc.

==== Protocol Notes ====
NONE - message types added or changed, new signals, etc.
  • Loading branch information
forslund committed Aug 3, 2017
1 parent a0ac65a commit db6127a
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions mycroft/skills/core.py
Expand Up @@ -360,8 +360,16 @@ def load_regex_files(self, regex_dir):
load_regex(regex_dir, self.emitter)

def __handle_stop(self, event):
"""
Handler for the "mycroft.stop" signal. Runs the user defined
`stop()` method.
"""
self.stop_time = time.time()
self.stop()
try:
self.stop()
except:
logger.error("Failed to stop skill: {}".format(self.name),
exc_info=True)

@abc.abstractmethod
def stop(self):
Expand All @@ -386,4 +394,8 @@ def shutdown(self):

self.emitter.emit(
Message("detach_skill", {"skill_name": self.name + ":"}))
self.stop()
try:
self.stop()
except:
logger.error("Failed to stop skill: {}".format(self.name),
exc_info=True)

0 comments on commit db6127a

Please sign in to comment.