1
0
Fork 0
mirror of https://github.com/uhIgnacio/EmoteManager.git synced 2024-08-15 02:23:13 +00:00

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
This commit is contained in:
Io Mintz 2019-10-10 00:28:49 +00:00
parent 97947e61c1
commit f6d9cea805

View file

@ -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():