FAQ | This is a LIVE service | Changelog

Commit 8a934ddc authored by Dr Rich Wareham's avatar Dr Rich Wareham
Browse files

retry after all errors

parent 1365b275
Pipeline #38292 passed with stages
in 3 minutes and 23 seconds
......@@ -24,13 +24,17 @@ def list_all(list_cb, *, page_size=500, retries=2, retry_delay=5, items_key='ite
try:
list_response = list_cb(pageToken=page_token, maxResults=page_size, **kwargs).execute()
except HttpError as err:
if (err.resp.status == 503 and retries > 0):
if (err.resp.status >= 400 and retries > 0):
retries -= 1
LOG.warn('503: Service unavailable - retrying')
LOG.warn('Error response: %s %s - retrying', err.resp.status, err.resp.reason)
sleep(retry_delay)
continue
if retries == 0:
LOG.error('503: Service unavailable - retry count exceeded')
LOG.error(
'Error response: %s %s - retry count exceeded', err.resp.status,
err.resp.reason
)
LOG.error('Error content: %r', err.content)
raise
resources.extend(list_response.get(items_key, []))
......@@ -153,13 +157,17 @@ def get_all_in_list(directory_service, get_cb, *, item_ids=[], id_key='key', bat
try:
batch.execute()
except HttpError as err:
if (err.resp.status == 503 and retries > 0):
if (err.resp.status >= 400 and retries > 0):
retries -= 1
LOG.warn('503: Service unavailable - retrying')
LOG.warn('Error response: %s %s - retrying', err.resp.status, err.resp.reason)
sleep(retry_delay)
continue
if retries == 0:
LOG.error('503: Service unavailable - retry count exceeded')
LOG.error(
'Error response: %s %s - retry count exceeded', err.resp.status,
err.resp.reason
)
LOG.error('Error content: %r', err.content)
raise
break
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment