mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-16 04:23:12 +00:00
Add exponentional backoff for ometa REST Client (#711)
Co-authored-by: Mithun Mathew <matt@Mithuns-MacBook-Pro.local>
This commit is contained in:
parent
79ca909f2f
commit
78e97c81ca
@ -124,23 +124,21 @@ class REST(object):
|
|||||||
else:
|
else:
|
||||||
opts['data'] = data
|
opts['data'] = data
|
||||||
|
|
||||||
retry = self._retry
|
total_retries = self._retry if self._retry > 0 else 0
|
||||||
if retry < 0:
|
retry = total_retries
|
||||||
retry = 0
|
|
||||||
while retry >= 0:
|
while retry >= 0:
|
||||||
try:
|
try:
|
||||||
logger.debug('URL {}, method {}'.format(url, method))
|
logger.debug('URL {}, method {}'.format(url, method))
|
||||||
logger.debug('Data {}'.format(opts))
|
logger.debug('Data {}'.format(opts))
|
||||||
return self._one_request(method, url, opts, retry)
|
return self._one_request(method, url, opts, retry)
|
||||||
except RetryException:
|
except RetryException:
|
||||||
retry_wait = self._retry_wait
|
retry_wait = self._retry_wait * (total_retries - retry + 1)
|
||||||
logger.warning(
|
logger.warning(
|
||||||
'sleep {} seconds and retrying {} '
|
'sleep {} seconds and retrying {} '
|
||||||
'{} more time(s)...'.format(
|
'{} more time(s)...'.format(
|
||||||
retry_wait, url, retry))
|
retry_wait, url, retry))
|
||||||
time.sleep(retry_wait)
|
time.sleep(retry_wait)
|
||||||
retry -= 1
|
retry -= 1
|
||||||
continue
|
|
||||||
|
|
||||||
def _one_request(self, method: str, url: URL, opts: dict, retry: int):
|
def _one_request(self, method: str, url: URL, opts: dict, retry: int):
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user