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

Revert "Gather update methods to update faster" #325

Closed
wants to merge 1 commit into from

Conversation

bdraco
Copy link
Contributor

@bdraco bdraco commented May 4, 2024

Reverts #301

home-assistant/core#116755

It turns out that some of the slower devices cannot respond within 10s to all the requests because the API is too slow.

While this will make updates much slower for faster devices, we still need to support the older slower ones.

@bdraco bdraco requested a review from mib1185 as a code owner May 4, 2024 15:39
@mib1185
Copy link
Owner

mib1185 commented May 4, 2024

can we increase the timeout to let's say 30s instead and keep the batch processing?

@bdraco
Copy link
Contributor Author

bdraco commented May 4, 2024

Changing the default timeout to 30s would probably work as well, however it won't fix anyone with a slow system who has manually set the timeout lower. We could do a one time options change to increase to 30s in the integration if its less than 30s, but we usually try not to alter user's settings. However its not common or a usual design to allow for a user configurable timeout in the first place, and would likely be rejected as an option for any new integration in code review as the timeout value is something developers should pick.

@bdraco
Copy link
Contributor Author

bdraco commented May 4, 2024

Also I think there is another issue going on here home-assistant/core#116755 (comment)

@mib1185
Copy link
Owner

mib1185 commented May 4, 2024

i meant so change the timeout just for this "bulk fetch" task - something like

async with asyncio.timeout(30)
    await asyncio.gather(*update_methods)

@mib1185
Copy link
Owner

mib1185 commented May 4, 2024

would likely be rejected as an option for any new integration in code review as the timeout value is something developers should pick.

i agree and already thought about removing both, the timeout and the scan interval option from the integration

@bdraco
Copy link
Contributor Author

bdraco commented May 4, 2024

i meant so change the timeout just for this "bulk fetch" task - something like

async with asyncio.timeout(30)
    await asyncio.gather(*update_methods)

Usually we want aiohttp to handle the timeout

self._aiohttp_timeout = aiohttp.ClientTimeout(total=timeout)
since if a timeout hits inside the asyncio.timeout context manager it will cancel all the tasks inside which sometimes leads to races in tearing down the connections which can make subsequent requests fail. That really shouldn't happen but it does in practice as we have to be sure everything inside an asyncio.timeout block is always cancellation safe. In theory aiohttp should be cancellation safe but we still see bug reports in the aiohttp issue queue where its not.

Another option might be to use gather_with_limited_concurrency https://github.com/home-assistant/core/blob/985fd499094297fc352e0c530e99264c0b742686/homeassistant/util/async_.py#L96 to reduce the number of requests.

I think before we know what to do we need to see if increasing the timeout works for the user

@bdraco
Copy link
Contributor Author

bdraco commented May 4, 2024

Let's hold off on this until we know if increasing the timeout to 30s solves the issue home-assistant/core#116755 (comment)

@bdraco bdraco marked this pull request as draft May 4, 2024 16:13
@mib1185
Copy link
Owner

mib1185 commented May 4, 2024

I think increasing the timeout to 30s should be sufficient - we have a quiet old and slow ds213+ home-assistant/core#116755 (comment) which is fine with 30s

@bdraco
Copy link
Contributor Author

bdraco commented May 4, 2024

Let's go with adjusting the default value in HA instead.

@bdraco bdraco closed this May 4, 2024
@bdraco bdraco deleted the revert-301-maybe_speed_up branch May 4, 2024 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants