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

drop the need to extend_timeout #62

Open
emphasize opened this issue Mar 15, 2023 · 5 comments
Open

drop the need to extend_timeout #62

emphasize opened this issue Mar 15, 2023 · 5 comments
Labels
wontfix This will not be worked on

Comments

@emphasize
Copy link
Member

This is a common message that is consumed by handle_skill_response during an active search:

{'phrase': 'regenbogen', ... , 'results': [{}], 'searching': False}

(searchingis always False no matter if a skill is searching)

to extend the timeout you need to self.extend_timeout() in a CPSkill which is sending

{'phrase': 'regenbogen', ..., 'timeout': x , 'searching': True}

to trigger the respective cases

if message.data.get("searching"):
# extend the timeout by N seconds
if timeout and self.settings.get("allow_extensions", True):
self.query_timeouts += timeout
# else -> expired search
else:
# Collect replies until the timeout
if not self.searching and not len(self.query_replies):
LOG.debug(" too late!! ignored in track selection process")
LOG.warning(
f"{message.data['skill_id']} is not answering fast "
"enough!")

While i see the potential goal to give the skill the freedom to extend to their liking (btw no skill is actually doing that - resulting in a problem when using OCPQuery().wait()), i don't like that implementation. It feels clumsy sending a search with "searching": False just to need another message to send the timeout amount with "searching": True cluttering the bus in the process.

@JarbasAl
Copy link
Member

I agree this is unclean, but it was the way original mycroft common play did (where OCP was born from)

I'm in favor of refactoring this one, but I'd like to keep the extend_timeout functionality around, OCP settings allows users to disable or limit this extension to protect against bad skills

@emphasize
Copy link
Member Author

emphasize commented Mar 15, 2023

Then we have to ensure CPSkills are actually doing this. I'm running into problems with only 3(!) skills around (tunein, youtube, news). And if more and more News stations are dripping in, this only gets worse. Tunein is naturally sending only a handful.

Besides, those have also to cap the match_confidence threshold worth sending. (I remember seeing a negative confidence with youtube, however this came to pass)

@emphasize
Copy link
Member Author

emphasize commented Mar 15, 2023

I'm hawking on this. what if in OVOSCommonPlaybackSkill Class (#) we

        for handler in self._search_handlers:
            ...
            
            # handler might return a generator or a list
            if isinstance(results, list):
                # inject skill id in individual results, will be needed later
                # for proper playback handling
                for idx, r in enumerate(results):
                    results[idx]["skill_id"] = self.skill_id
                self.bus.emit(message.response({"phrase": search_phrase,
                                                "skill_id": self.skill_id,
                                                "skill_name": self.name,
                                                "thumbnail": self.skill_icon,
                                                "results": results,
                                                "timeout": self.search_timeout}))

making search_timeout a property? We can even make it a user setting.

@JarbasAl
Copy link
Member

so instead of a bool we return an int for timeout, where 0 would be equivalent to "searching":False ?

@emphasize
Copy link
Member Author

emphasize commented Mar 15, 2023

you mean instead of a separate message that carries the amount and searching true. Where's the problem?
If we really need searching, we can add it. But i'm under the impression this is only needed for this one case posted at the top.

@JarbasAl JarbasAl added the wontfix This will not be worked on label May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants