diff --git a/mycroft/skills/core.py b/mycroft/skills/core.py index 18bd5a33a7..dc27141c95 100644 --- a/mycroft/skills/core.py +++ b/mycroft/skills/core.py @@ -252,7 +252,7 @@ class MycroftSkill(object): self.stop_time = time.time() self.stop_threshold = self.config_core.get("skills").get( 'stop_threshold') - self.emitter.on('mycroft.stop', self.__handle_stop) + self.add_event('mycroft.stop', self.__handle_stop, False) def detach(self): for (name, intent) in self.registered_intents: @@ -304,7 +304,7 @@ class MycroftSkill(object): _intent_list = [] _intent_file_list = [] - def add_event(self, name, handler, need_self): + def add_event(self, name, handler, need_self=False): """ Create event handler for executing intent @@ -518,6 +518,7 @@ class MycroftSkill(object): # removing events for e, f in self.events: self.emitter.remove(e, f) + self.events = None # Remove reference to wrappers self.emitter.emit( Message("detach_skill", {"skill_id": str(self.skill_id) + ":"})) diff --git a/mycroft/skills/scheduled_skills.py b/mycroft/skills/scheduled_skills.py index 87c07cc516..7d56db515d 100644 --- a/mycroft/skills/scheduled_skills.py +++ b/mycroft/skills/scheduled_skills.py @@ -116,7 +116,11 @@ class ScheduledSkill(MycroftSkill): def shutdown(self): super(ScheduledSkill, self).shutdown() + # if timer method is running wait for it to complete self.cancel() + if self.timer and self.timer.isAlive(): + self.timer.join() + self.timer = None class ScheduledCRUDSkill(ScheduledSkill):