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

Switch hassio to use iter_chunks #102031

Merged
merged 2 commits into from
Oct 15, 2023
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
5 changes: 4 additions & 1 deletion homeassistant/components/hassio/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,10 @@ async def _handle(self, request: web.Request, path: str) -> web.StreamResponse:
if should_compress(response.content_type):
response.enable_compression()
await response.prepare(request)
async for data in client.content.iter_chunked(8192):
# In testing iter_chunked, iter_any, and iter_chunks:
# iter_chunks was the best performing option since
# it does not have to do as much re-assembly
async for data, _ in client.content.iter_chunks():
await response.write(data)

return response
Expand Down
5 changes: 4 additions & 1 deletion homeassistant/components/hassio/ingress.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,10 @@ async def _handle_request(
if should_compress(response.content_type):
response.enable_compression()
await response.prepare(request)
async for data in result.content.iter_chunked(8192):
# In testing iter_chunked, iter_any, and iter_chunks:
# iter_chunks was the best performing option since
# it does not have to do as much re-assembly
async for data, _ in result.content.iter_chunks():
await response.write(data)

except (
Expand Down