Skip to content
This repository has been archived by the owner on Sep 8, 2024. It is now read-only.

Added comments to document race condition #2945

Merged
merged 1 commit into from
Jul 7, 2021
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
11 changes: 10 additions & 1 deletion mycroft/skills/mycroft_skill/mycroft_skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,16 @@ def converse(self, message=None):
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,12 @@ def check_contains(message):
@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',
Expand Down