From 18cb28088d5da217eecd0bc39a0d83db88cc53b9 Mon Sep 17 00:00:00 2001 From: Chris Veilleux Date: Tue, 6 Jul 2021 13:48:52 -0500 Subject: [PATCH] Added comments to document race condition --- mycroft/skills/mycroft_skill/mycroft_skill.py | 11 ++++++++++- .../features/steps/utterance_responses.py | 6 ++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/mycroft/skills/mycroft_skill/mycroft_skill.py b/mycroft/skills/mycroft_skill/mycroft_skill.py index 4302b49b4c..67bfac529f 100644 --- a/mycroft/skills/mycroft_skill/mycroft_skill.py +++ b/mycroft/skills/mycroft_skill/mycroft_skill.py @@ -411,7 +411,16 @@ class MycroftSkill: return False def __get_response(self): - """Helper to get a reponse from the user + """Helper to get a response from the user + + NOTE: There is a race condition here. There is a small amount of + time between the end of the device speaking and the converse method + being overridden in this method. If an utterance is injected during + this time, the wrong converse method is executed. The condition is + hidden during normal use due to the amount of time it takes a user + to speak a response. The condition is revealed when an automated + process injects an utterance quicker than this method can flip the + converse methods. Returns: str: user's response or None on a timeout diff --git a/test/integrationtests/voight_kampff/features/steps/utterance_responses.py b/test/integrationtests/voight_kampff/features/steps/utterance_responses.py index b0d118a328..7fd1c19912 100644 --- a/test/integrationtests/voight_kampff/features/steps/utterance_responses.py +++ b/test/integrationtests/voight_kampff/features/steps/utterance_responses.py @@ -235,6 +235,12 @@ def then_contains(context, text): @then('the user replies "{text}"') @then('the user says "{text}"') def then_user_follow_up(context, text): + """Send a user response after being prompted by device. + + The sleep after the device is finished speaking is to address a race + condition in the MycroftSkill base class conversational code. It can + be removed when the race condition is addressed. + """ wait_while_speaking() time.sleep(2) context.bus.emit(Message('recognizer_loop:utterance',