LoggingRetry#
API documentation for tradingstrategy.utils.logging_retry.LoggingRetry Python class in Trading Strategy framework.
- class LoggingRetry[source]#
- Bases: - Retry- In the case we need to throttle Coingecko or other HTTP API, be verbose about it. - Example how to use: - # Set up dealing with network connectivity flakey if retry_policy is None: # https://stackoverflow.com/a/35504626/315168 retry_policy = LoggingRetry( total=5, backoff_factor=0.1, status_forcelist=[ 500, 502, 503, 504 ], ) session.mount('http://', HTTPAdapter(max_retries=retry_policy)) session.mount('https://', HTTPAdapter(max_retries=retry_policy)) - Methods - __init__(*args, **kwargs)- from_int(retries[, redirect, default])- Backwards-compatibility for the old retries format. - get_backoff_time()- Formula for computing the current backoff - get_retry_after(response)- Get the value of Retry-After in seconds. - increment([method, url, response, error, ...])- Return a new Retry object with incremented retry counters. - is_exhausted()- Are we out of retries? - is_retry(method, status_code[, has_retry_after])- Is this method/status code retryable? (Based on allowlists and control variables such as the number of total retries to allow, whether to respect the Retry-After header, whether this header is present, and whether the returned status code is on the list of status codes to be retried upon on the presence of the aforementioned header) - new(**kw)- parse_retry_after(retry_after)- sleep([response])- Sleep between retry attempts. - sleep_for_retry(response)- Attributes - DEFAULT- DEFAULT_ALLOWED_METHODS- Default methods to be used for - allowed_methods- DEFAULT_BACKOFF_MAX- Default maximum backoff time. - DEFAULT_REMOVE_HEADERS_ON_REDIRECT- Default headers to be used for - remove_headers_on_redirect- RETRY_AFTER_STATUS_CODES- Default status codes to be used for - status_forcelist- increment(method=None, url=None, response=None, error=None, _pool=None, _stacktrace=None)[source]#
- Return a new Retry object with incremented retry counters. - Parameters:
- response ( - BaseHTTPResponse) – A response object, or None, if the server did not return a response.
- error (Exception) – An error encountered during the request, or None if the response was received successfully. 
 
- Returns:
- A new - Retryobject.