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

fix: stop DRY #325

Merged
merged 1 commit into from
Jan 9, 2025
Merged
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
18 changes: 1 addition & 17 deletions ovos_workshop/skills/ovos.py
Original file line number Diff line number Diff line change
Expand Up @@ -1166,7 +1166,7 @@ def _register_system_event_handlers(self):
"""
Register default messagebus event handlers
"""
self.add_event('mycroft.stop', self._handle_stop, speak_errors=False)
self.add_event('mycroft.stop', self._handle_session_stop, speak_errors=False)
self.add_event(f"{self.skill_id}.stop", self._handle_session_stop, speak_errors=False)
self.add_event(f"{self.skill_id}.stop.ping", self._handle_stop_ack, speak_errors=False)

Expand Down Expand Up @@ -1356,22 +1356,6 @@ def _handle_session_stop(self, message: Message):
self.__responses[sess.session_id] = None # abort any ongoing get_response
self.bus.emit(message.reply(f"{self.skill_id}.stop.response", data))

def _handle_stop(self, message):
"""Handler for the "mycroft.stop" signal. Runs the user defined
`stop()` method.
"""
message.context['skill_id'] = self.skill_id
self.bus.emit(message.forward(self.skill_id + ".stop"))
sess = SessionManager.get(message)
try:
stopped = self.stop_session(sess) or self.stop() or False
LOG.debug(f"{self.skill_id} stopped: {stopped}")
if stopped:
self.bus.emit(message.reply("mycroft.stop.handled",
{"by": "skill:" + self.skill_id}))
except Exception as e:
self.log.exception(f'Failed to stop skill: {self.skill_id}: {e}')

def default_shutdown(self):
"""
Parent function called internally to shut down everything.
Expand Down
Loading