Skip to content

Commit

Permalink
Possibly solve intermittent permission issues (#335)
Browse files Browse the repository at this point in the history
* Move maybe_refresh inside retry loop

* move it around

need to remake request after possible refresh

* undo

* bad list

* conf

* lint

* format
  • Loading branch information
martindurant authored Jan 28, 2021
1 parent 98dbd55 commit 1b5d772
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
20 changes: 10 additions & 10 deletions gcsfs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,13 +500,15 @@ async def _call(
self, method, path, *args, json_out=False, info_out=False, **kwargs
):
logger.debug(f"{method.upper()}: {path}, {args}, {kwargs}")
self.maybe_refresh()
path, jsonin, datain, headers, kwargs = self._get_args(path, *args, **kwargs)

for retry in range(self.retries):
try:
if retry > 0:
await asyncio.sleep(min(random.random() + 2 ** (retry - 1), 32))
self.maybe_refresh()
path, jsonin, datain, headers, kwargs = self._get_args(
path, *args, **kwargs
)
async with self.session.request(
method=method,
url=path,
Expand Down Expand Up @@ -1152,14 +1154,12 @@ def find(self, path, withdirs=False, detail=False, prefix="", **kwargs):
)
if not out and key:
try:
out = [
sync(
self.loop,
self._get_object,
path,
callback_timeout=self.callback_timeout,
)
]
out = sync(
self.loop,
self._get_object,
path,
callback_timeout=self.callback_timeout,
)
except FileNotFoundError:
out = []
dirs = []
Expand Down
5 changes: 5 additions & 0 deletions gcsfs/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
import vcr.stubs.aiohttp_stubs as aios


import fsspec.config

fsspec.config.conf.pop("gcs", None)


@pytest.yield_fixture
def token_restore():
cache = GCSFileSystem.tokens
Expand Down

0 comments on commit 1b5d772

Please sign in to comment.