AsyncLocal
Description:
- Work with your local filesystem asynchronously
Resources:
Example 1
Section titled “Example 1”Save a text file asynchronously to your local filesystem
import asynciofrom morefs.asyn_local import AsyncLocalFileSystemfrom pathlib import Path
fp = "/tmp/ganymede_demo"tfp = f"{fp}/test.txt"path = Path(fp).mkdir(exist_ok=True)
async def main(): fs = AsyncLocalFileSystem(auto_mkdir=False)
async with fs.open_async(tfp, mode="w") as f: await f.write("foobar")
content = await fs._cat(tfp) print(content)
# Alternatively, you can still use sync methods print(fs.cat(tfp))
asyncio.run(main())ganymede is made by Eugo