Skip to content

Commit

Permalink
Fetch entire attachment rather than iterate on it
Browse files Browse the repository at this point in the history
  • Loading branch information
rbw committed Oct 13, 2020
1 parent 02c44a7 commit 4f1f320
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions aiosnow/models/attachment/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@ async def download(self, selection: Union[Selector, Condition, str], dst_dir="."
)
file = FileWriter(attachment["file_name"])
with file as f:
# The idea here is to fetch chunks of data as yielded
# by the API and write directly to the file's buffer.
async for data_chunk, _ in response.content.iter_chunks():
await self.loop.run_in_executor(self.io_pool_exc, f.write, data_chunk)
await self.loop.run_in_executor(self.io_pool_exc, f.write, await response.read())

return file

Expand Down

0 comments on commit 4f1f320

Please sign in to comment.