Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/issue 1014 #1018

Merged
merged 2 commits into from
Aug 31, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions mycroft/skills/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def __register_stop(self):
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:
Expand Down Expand Up @@ -304,7 +304,7 @@ def _register_decorated(self):
_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

Expand Down Expand Up @@ -518,6 +518,7 @@ def shutdown(self):
# 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) + ":"}))
Expand Down
8 changes: 8 additions & 0 deletions mycroft/skills/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,14 @@ def _watch_skills():
logger.debug("Reloading Skill: " + skill_folder)
# removing listeners and stopping threads
skill["instance"].shutdown()

# - 2 since there are two local references that are known
refs = sys.getrefcount(skill["instance"]) - 2
if refs > 0:
logger.warn("After shutdown of {} there are still "
"{} references remaining. The skill "
"won't be cleaned from memory."
.format(skill['instance'].name, refs))
del skill["instance"]
skill["loaded"] = True
skill["instance"] = load_skill(
Expand Down
4 changes: 4 additions & 0 deletions mycroft/skills/scheduled_skills.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@ def notify(self, timestamp):

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):
Expand Down