Fix issue where skills fail during initialize()
An exception in skill's initialize method would be reraised and cause
the main loading routine to halt. This does not reraise the exception,
instead the instance reference is removed.
@@ -164,9 +164,9 @@ class SkillLoader:
self._skip_load()
else:
skill_module = self._load_skill_source()
- if skill_module is not None:
- self._create_skill_instance(skill_module)
+ if skill_module and self._create_skill_instance(skill_module):
self._check_for_first_run()
+ self.loaded = True
self.last_loaded = time()
self._communicate_load_status()
@@ -210,7 +210,14 @@ class SkillLoader:
def _create_skill_instance(self, skill_module):
"""Use v2 skills framework to create the skill."""
+ try:
self.instance = skill_module.create_skill()
+ except Exception as e:
+ log_msg = 'Skill __init__ failed with {}'
+ LOG.exception(log_msg.format(repr(e)))
+ self.instance = None
+
+ if self.instance:
self.instance.skill_id = self.skill_id
self.instance.settings.allow_overwrite = True
self.instance.settings.load_skill_settings_from_file()
@@ -222,12 +229,14 @@ class SkillLoader:
self.instance._register_decorated()
self.instance.register_resting_screen()
self.instance.initialize()
- except Exception:
+ except Exception as e:
# If an exception occurs, make sure to clean up the skill
self.instance.default_shutdown()
- raise
+ self.instane = None
+ log_msg = 'Skill initialization failed with {}'
+ LOG.exception(log_msg.format(repr(e)))
- self.loaded = True
+ return self.instance is not None
def _check_for_first_run(self):
"""The very first time a skill is run, speak the intro."""
