Skip to content

Commit

Permalink
Troubleshooting test failure race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonDaniel committed May 31, 2024
1 parent 95e681b commit 903ce4e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions neon_utils/skills/kiosk_skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import datetime

from abc import abstractmethod
from threading import Thread
from threading import Thread, Event
from time import time
from ovos_bus_client import Message
from ovos_utils.log import LOG
Expand Down Expand Up @@ -154,20 +154,24 @@ def converse(self, message: Message = None):
self.bus.emit(message.forward("mycroft.stop"))
return True
LOG.debug(f"Consuming utterance from {user}")
Thread(target=self._handle_converse, args=(message,),
handled = Event()
Thread(target=self._handle_converse, args=(message, handled),
daemon=True).start()
if not handled.wait(3):
raise TimeoutError("")
return True
return False

def _handle_converse(self, message: Message):
def _handle_converse(self, message: Message, handled: Event):
"""
Handle actual converse interaction in a thread so the skills service can
get a `handled` response immediately
"""
user = get_message_user(message)
LOG.info(f"handle converse for: {user}")
self.handle_user_utterance(message)
self._active_users[user] = time()
handled.set()
self.handle_user_utterance(message)
self._timeout_timer(message)

def _timeout_timer(self, message: Message):
Expand Down

0 comments on commit 903ce4e

Please sign in to comment.