-
-
Notifications
You must be signed in to change notification settings - Fork 36.2k
Update service call return values and error handling #94657
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
Conversation
|
It looks like the only thing that explicitly sets a limit for timeout is intents. It sets a short timeout of 200ms to attempt to pass validation but then doesn't want to block on the result. |
|
Changing the timeout behavior now has these remaining failing tests: |
|
The reason why awaiting the coro directly in |
allenporter
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reviewed your changes and they look good.
Co-authored-by: Martin Hjelmare <[email protected]>
|
When we're finished with all the changes around services we should publish a developer blog. |
I have home-assistant/developers.home-assistant#1799 (linked from this PR) so we don't forget and we can keep adding to it with the other upcoming service response data changes. |
homeassistant/helpers/script.py
Outdated
| if limit is not None: | ||
| # There is a call limit, so just wait for it to finish. | ||
| await service_task | ||
| try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This timeout disappeared and i can't tell where it went or why we did this looking at the PR and commit history. Is the lack of timeout here responsible for #98073 ? or are we expecting a timeout somewhere else?
Proposed change
Update the return signature of service calls:
Previously this would return True on success and False on timeout with a default limit of 10 seconds. Instead, we can handle any timeouts needed in the caller based on the context where they are called from (e.g. script can use an asyncio timeout if it wants a timeout).
Script service call limit has been removed. We can consider adding this back in the future with an explicit limit in the script. The main point is we can reduce a lot of complexity now by not supporting this.
Intent service call timeouts were rewritten to attempt to preserve existing behavior of starting an async call, blocking for a short timeout, then proceeding.
Type of change
Additional information
Checklist
black --fast homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all..coveragerc.To help with the load of incoming pull requests: