Skip to content

Description:

  • Work with your local filesystem asynchronously

Resources:

Save a text file asynchronously to your local filesystem

import asyncio
from morefs.asyn_local import AsyncLocalFileSystem
from 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