mirror of
https://github.com/GAM-team/GAM.git
synced 2026-07-06 13:51:36 +00:00
retry on ServerNotFound DNS issues
This commit is contained in:
18
src/gam.py
18
src/gam.py
@@ -1066,7 +1066,13 @@ def callGAPI(service, function,
|
|||||||
service._http.cache = None
|
service._http.cache = None
|
||||||
continue
|
continue
|
||||||
systemErrorExit(4, str(e))
|
systemErrorExit(4, str(e))
|
||||||
except (TypeError, httplib2.ServerNotFoundError, RuntimeError) as e:
|
except (httplib2.ServerNotFoundError, RuntimeError) as e:
|
||||||
|
if (n != retries):
|
||||||
|
service._http.connections = {}
|
||||||
|
waitOnFailure(n, retries, str(e))
|
||||||
|
continue
|
||||||
|
systemErrorExit(4, str(e))
|
||||||
|
except TypeError as e:
|
||||||
systemErrorExit(4, str(e))
|
systemErrorExit(4, str(e))
|
||||||
|
|
||||||
def callGAPIpages(service, function, items='items',
|
def callGAPIpages(service, function, items='items',
|
||||||
@@ -1257,6 +1263,10 @@ def getService(api, http):
|
|||||||
http.cache = None
|
http.cache = None
|
||||||
return service
|
return service
|
||||||
except (httplib2.ServerNotFoundError, RuntimeError) as e:
|
except (httplib2.ServerNotFoundError, RuntimeError) as e:
|
||||||
|
if n != retries:
|
||||||
|
http.connections = {}
|
||||||
|
waitOnFailure(n, retries, str(e))
|
||||||
|
continue
|
||||||
systemErrorExit(4, str(e))
|
systemErrorExit(4, str(e))
|
||||||
except (googleapiclient.errors.InvalidJsonError, KeyError, ValueError) as e:
|
except (googleapiclient.errors.InvalidJsonError, KeyError, ValueError) as e:
|
||||||
http.cache = None
|
http.cache = None
|
||||||
@@ -1384,10 +1394,16 @@ def buildGAPIServiceObject(api, act_as, showAuthError=True):
|
|||||||
GM_Globals[GM_CURRENT_API_SCOPES] = API_SCOPE_MAPPING[api]
|
GM_Globals[GM_CURRENT_API_SCOPES] = API_SCOPE_MAPPING[api]
|
||||||
credentials = getSvcAcctCredentials(GM_Globals[GM_CURRENT_API_SCOPES], act_as)
|
credentials = getSvcAcctCredentials(GM_Globals[GM_CURRENT_API_SCOPES], act_as)
|
||||||
request = google_auth_httplib2.Request(http)
|
request = google_auth_httplib2.Request(http)
|
||||||
|
retries = 3
|
||||||
|
for n in range(1, retries+1):
|
||||||
try:
|
try:
|
||||||
credentials.refresh(request)
|
credentials.refresh(request)
|
||||||
service._http = google_auth_httplib2.AuthorizedHttp(credentials, http=http)
|
service._http = google_auth_httplib2.AuthorizedHttp(credentials, http=http)
|
||||||
except (httplib2.ServerNotFoundError, RuntimeError) as e:
|
except (httplib2.ServerNotFoundError, RuntimeError) as e:
|
||||||
|
if n != retries:
|
||||||
|
http.connections = {}
|
||||||
|
waitOnFailure(n, retries, str(e))
|
||||||
|
continue
|
||||||
systemErrorExit(4, e)
|
systemErrorExit(4, e)
|
||||||
except google.auth.exceptions.RefreshError as e:
|
except google.auth.exceptions.RefreshError as e:
|
||||||
if isinstance(e.args, tuple):
|
if isinstance(e.args, tuple):
|
||||||
|
|||||||
Reference in New Issue
Block a user