Tinche / aiofiles

File support for asyncio
Apache License 2.0
2.66k stars 150 forks source link

does aiofiles support tar files? #127

Closed mengwanguc closed 2 years ago

mengwanguc commented 2 years ago

Hello,

Can we use aiofiles to asynchronously read tar files?

Synchronously, we can do this using tarfile:

with tarfile.open(path) as archive:
        for entry in archive.getmembers():
            with archive.extractfile(entry) as f:
                contents = f.read()

Is there an async way to do this hopefully with the help of aiofiles?

Tinche commented 2 years ago

Yeah, put that code into a function and run it using get_running_loop().run_in_executor(None, func) ;)

I think this would be a little out of scope of aiofiles.