Skip to content

Commit

Permalink
Retry on auth refresh error.
Browse files Browse the repository at this point in the history
Retry on requests failing due to `google.auth.exceptions.RefreshError`,
partial resolution of fsspec#71.
  • Loading branch information
asford committed Feb 14, 2018
1 parent 7ad092c commit 2ccf856
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion gcsfs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from base64 import b64encode
import google.auth as gauth
from google.auth.transport.requests import AuthorizedSession
from google.auth.exceptions import GoogleAuthError
from google.oauth2.credentials import Credentials
from google_auth_oauthlib.flow import InstalledAppFlow
from google.oauth2 import service_account
Expand Down Expand Up @@ -391,7 +392,7 @@ def _call(self, method, path, *args, **kwargs):
r = meth(self.base + path, params=kwargs, json=json)
validate_response(r, path)
break
except (HtmlError, RequestException) as e:
except (HtmlError, RequestException, GoogleAuthError) as e:
logger.exception("_call exception: %s", e)
if retry == self.retries - 1:
raise e
Expand Down
4 changes: 3 additions & 1 deletion gcsfs/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import requests.exceptions
import google.auth.exceptions


def seek_delimiter(file, delimiter, blocksize):
Expand Down Expand Up @@ -106,7 +107,8 @@ def __init__(self, error_response=None):
requests.exceptions.Timeout,
requests.exceptions.ProxyError,
requests.exceptions.SSLError,
requests.exceptions.ContentDecodingError
requests.exceptions.ContentDecodingError,
google.auth.exceptions.RefreshError,
)


Expand Down

0 comments on commit 2ccf856

Please sign in to comment.