Skip to content

Commit

Permalink
Optimized batch read for better memory efficiency
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyCvn committed Dec 14, 2023
1 parent 9805545 commit a05487a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions reduct/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,14 @@ async def parse_batched_records(resp: ClientResponse) -> AsyncIterator[Record]:


async def _read_response(resp, content_length):
buffer = b""
chunks = []
count = 0
while True:
n = min(CHUNK_SIZE, content_length - count)
chunk = await resp.content.read(n)
buffer += chunk
chunks.append(chunk)
count += len(chunk)

if count == content_length:
break
return buffer
return b"".join(chunks)

0 comments on commit a05487a

Please sign in to comment.