Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions kerchunk/sync_wrapper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import inspect
from fsspec.asyn import AsyncFileSystem


class SynchronousWrapper(AsyncFileSystem):
"""If the calling code requires an async filesystem, but you have sync"""

def __init__(self, fs, **kw):
self.fs = fs
super().__init__(**kw)

def __getattribute__(self, item):
fs = object.__getattribute__(self, "fs")
if inspect.iscoroutinefunction(getattr(AsyncFileSystem, item)):

async def f(*args, **kwargs):
return getattr(fs, item.lstrip("_"))(*args, **kwargs)

return f
else:
return getattr(fs, item)
Loading