From 4f1f3209b2db93e9db72bb289ec073180946b7a4 Mon Sep 17 00:00:00 2001 From: Robert Wikman Date: Wed, 14 Oct 2020 00:00:52 +0200 Subject: [PATCH] Fetch entire attachment rather than iterate on it --- aiosnow/models/attachment/model.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/aiosnow/models/attachment/model.py b/aiosnow/models/attachment/model.py index ac0d518..cadbc73 100644 --- a/aiosnow/models/attachment/model.py +++ b/aiosnow/models/attachment/model.py @@ -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