From f6d9cea805012d15c2c444dd41cec2865c4033f3 Mon Sep 17 00:00:00 2001 From: Io Mintz Date: Thu, 10 Oct 2019 00:28:49 +0000 Subject: [PATCH] simplify utils.archive.extract_async and stop ignoring the size_limit kwarg Getting the initial generator in an executor is misguided since it does not actually begin executing until primed --- utils/archive.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/utils/archive.py b/utils/archive.py index f142068..0224132 100644 --- a/utils/archive.py +++ b/utils/archive.py @@ -70,8 +70,7 @@ def extract_tar(archive, *, size_limit=None): yield ArchiveInfo(member.name, content=tar.extractfile(member).read(), error=None) async def extract_async(archive: typing.io.BinaryIO, size_limit=None): - gen = await asyncio.get_event_loop().run_in_executor(None, extract, archive) - for x in gen: + for x in extract(archive, size_limit=size_limit): yield await asyncio.sleep(0, x) def main():