Skip to content

Commit

Permalink
configurable timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl committed Jun 19, 2024
1 parent f5ddf57 commit c2bbede
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ovos_workshop/skills/ovos.py
Original file line number Diff line number Diff line change
Expand Up @@ -1856,20 +1856,21 @@ def __get_response(self, session: Session):
ans = []

start = time.time()
timeout = self.config_core.get("skills", {}).get("get_response_timeout", 20)

def on_extension(msg):
nonlocal start
s = SessionManager.get(msg)
if s.session_id == session.session_id:
# this helps with slower voice satellites or in cases of very long responses
LOG.debug(f"Extending get_response wait time: {msg.msg_type}")
start = time.time()
start = time.time() # reset timer

# if we have indications listener is busy, we allow extra time
self.bus.on("recognizer_loop:record_begin", on_extension)
self.bus.on("recognizer_loop:record_end", on_extension)

while time.time() - start <= 15 and not ans:
while time.time() - start <= timeout and not ans:
ans = self.__responses[session.session_id]
# NOTE: a threading.Event is not used otherwise we can't raise the
# AbortEvent exception to kill the thread
Expand Down

0 comments on commit c2bbede

Please sign in to comment.