Skip to content

Commit

Permalink
Switch hassio to use iter_chunks (#102031)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Oct 15, 2023
1 parent 471d1ab commit 6830462
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
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

0 comments on commit 6830462

Please sign in to comment.