def wrapper(*args, **kwargs): response = f(*args, **kwargs) if response.status_code in TenableIOClient._RETRY_STATUS_CODES: raise TenableIORetryableApiException(response) if not 200 <= response.status_code <= 299: raise TenableIOApiException(response) return response
def wrapper(*args, **kwargs): total_retries = int(TenableIOClient._TOTAL_RETRIES) count = 0 sleep_ms = 0 if 'headers' not in kwargs or not kwargs['headers']: kwargs['headers'] = {} while count <= total_retries: # Set retry count header if count > 0: kwargs['headers'].update( {u'X-Tio-Retry-Count': str(count)}) count += 1 try: return f(*args, **kwargs) except TenableIORetryableApiException as exception: if count > total_retries: raise TenableIOApiException(exception.response) sleep_ms += count * int( TenableIOClient._RETRY_SLEEP_MILLISECONDS) sleep(sleep_ms / 1000.0) logging.warn(u'RETRY(%d/%d)AFTER(%dms):%s' % (count, total_retries, sleep_ms, format_request(exception.response)))
def wrapper(*args, **kwargs): response = f(*args, **kwargs) if response.status_code == 429: raise TenableIORetryableApiException(response) if response.status_code in [501, 502, 503, 504]: raise TenableIORetryableApiException(response) if not 200 <= response.status_code <= 299: raise TenableIOApiException(response) return response
def wrapper(*args, **kwargs): count = 0 retry = True sleep_ms = 0 while retry: retry = False try: return f(*args, **kwargs) except TenableIORetryableApiException as exception: count += 1 if count <= TenableIOClient.MAX_RETRIES: retry = True sleep_ms += count * TenableIOClient.RETRY_SLEEP_MILLISECONDS logging.warn(u'RETRY(%d/%d)AFTER(%dms):%s' % (count, TenableIOClient.MAX_RETRIES, sleep_ms, format_request(exception.response))) sleep(sleep_ms / 1000.0) else: raise TenableIOApiException(exception.response)
def wrapper(*args, **kwargs): count = 0 retry = True sleep_ms = 0 while retry: retry = False try: return f(*args, **kwargs) except TenableIORetryableApiException as exception: count += 1 if count <= TenableIOClient.MAX_RETRIES: retry = True sleep_ms += count * TenableIOClient.RETRY_SLEEP_MILLISECONDS Logger.warn( u'Retry %d of %d. Sleep %dms' % (count, TenableIOClient.MAX_RETRIES, sleep_ms), TenableIOClient) sleep(sleep_ms / 1000.0) else: raise TenableIOApiException(exception.response)
def wrapper(*args, **kwargs): response = f(*args, **kwargs) if not 200 <= response.status_code <= 299: raise TenableIOApiException(response) return response