Skip to content

Commit 07d51a4

Browse files
author
Martin Durant
committed
more maybe sync
1 parent 47f1a77 commit 07d51a4

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

s3fs/core.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,7 @@ async def _call_s3(self, method, *akwarglist, **kwargs):
203203
**kwargs)
204204
for i in range(self.retries):
205205
try:
206-
out = await method(**additional_kwargs)
207-
locals().pop("err", None) # break cycle following retry
208-
return out
206+
return await method(**additional_kwargs)
209207
except S3_RETRYABLE_ERRORS as e:
210208
logger.debug("Retryable error: %s" % e)
211209
err = e
@@ -483,7 +481,7 @@ async def _find(self, path, maxdepth=None, withdirs=None, detail=False):
483481
return {o['name']: o for o in out}
484482
return [o['name'] for o in out]
485483

486-
#find = sync_wrapper(_find)
484+
find = sync_wrapper(_find)
487485

488486
async def _mkdir(self, path, acl="", create_parents=True, **kwargs):
489487
path = self._strip_protocol(path).rstrip('/')
@@ -857,7 +855,7 @@ def isdir(self, path):
857855
return False
858856

859857
# This only returns things within the path and NOT the path object itself
860-
return bool(sync(self.loop, self._lsdir, path))
858+
return bool(maybe_sync(self._lsdir, self, path))
861859

862860
def ls(self, path, detail=False, refresh=False, **kwargs):
863861
""" List single "directory" with or without details
@@ -875,9 +873,9 @@ def ls(self, path, detail=False, refresh=False, **kwargs):
875873
additional arguments passed on
876874
"""
877875
path = self._strip_protocol(path).rstrip('/')
878-
files = sync(self.loop, self._ls, path, refresh=refresh)
876+
files = maybe_sync(self._ls, self, path, refresh=refresh)
879877
if not files:
880-
files = sync(self.loop, self._ls, self._parent(path), refresh=refresh)
878+
files = maybe_sync(self._ls, self, self._parent(path), refresh=refresh)
881879
files = [o for o in files if o['name'].rstrip('/') == path
882880
and o['type'] != 'directory']
883881
if detail:
@@ -1082,7 +1080,7 @@ def url(self, path, expires=3600, **kwargs):
10821080
the number of seconds this signature will be good for.
10831081
"""
10841082
bucket, key, version_id = self.split_path(path)
1085-
return sync(self.loop, self.s3.generate_presigned_url,
1083+
return maybe_sync(self.s3.generate_presigned_url, self,
10861084
ClientMethod='get_object',
10871085
Params=dict(Bucket=bucket, Key=key, **version_id_kw(version_id), **kwargs),
10881086
ExpiresIn=expires)
@@ -1276,7 +1274,7 @@ def rm(self, path, recursive=False, **kwargs):
12761274
bucket, key, _ = self.split_path(path)
12771275
if not key and self.is_bucket_versioned(bucket):
12781276
# special path to completely remove versioned bucket
1279-
sync(self.loop, self._rm_versioned_bucket_contents, bucket)
1277+
maybe_sync(self._rm_versioned_bucket_contents, self, bucket)
12801278
super().rm(path, recursive=recursive, **kwargs)
12811279

12821280
def invalidate_cache(self, path=None):

0 commit comments

Comments
 (0)