Skip to content

Commit

Permalink
Avoid trying to async-wrap properties
Browse files Browse the repository at this point in the history
  • Loading branch information
moradology committed Nov 5, 2024
1 parent 38d3cdb commit 394e032
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions fsspec/implementations/asyn_wrapper.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asyncio
import inspect
import functools
from fsspec.asyn import AsyncFileSystem

Expand Down Expand Up @@ -43,13 +44,22 @@ def __init__(self, sync_fs, *args, **kwargs):
self.fs = sync_fs
self._wrap_all_sync_methods()

@property
def fsid(self):
return f"async_{self.fs.fsid}"

def _wrap_all_sync_methods(self):
"""
Wrap all synchronous methods of the underlying filesystem with asynchronous versions.
"""
for method_name in dir(self.fs):
if method_name.startswith("_"):
continue

attr = inspect.getattr_static(self.fs, method_name)
if isinstance(attr, property):
continue

method = getattr(self.fs, method_name)
if callable(method) and not asyncio.iscoroutinefunction(method):
async_method = async_wrapper(method, obj=self)
Expand Down

0 comments on commit 394e032

Please sign in to comment.