class documentation

class ResilientSession(Session): (source)

View In Hierarchy

This class is supposed to retry requests that do return temporary errors. :py:meth:`__recoverable` handles all retry-able errors.

Method __init__ A Session subclass catered for the Jira API with exponential delaying retry.
Method request This is an intentional override of `Session.request()` to inject some error handling and retry logic.
Instance Variable headers Undocumented
Instance Variable max_retries Undocumented
Instance Variable max_retry_delay Undocumented
Instance Variable timeout Undocumented
Method __handle_known_ok_response_errors Responses that report ok may also have errors.
Method __recoverable Return whether the request is recoverable and hence should be retried.
Method _jira_prepare Do any pre-processing of our own and return the updated kwargs.
def __init__(self, timeout=None, max_retries: int = 3, max_retry_delay: int = 60): (source)

A Session subclass catered for the Jira API with exponential delaying retry. Args: timeout (Optional[Union[Union[float, int], Tuple[float, float]]]): Connection/read timeout delay. Defaults to None. max_retries (int): Max number of times to retry a request. Defaults to 3. max_retry_delay (int): Max delay allowed between retries. Defaults to 60.

def request(self, method: str, url: Union[str, bytes], _prepare_retry_class: PrepareRequestForRetry = PassthroughRetryPrepare(), **kwargs) -> Response: (source)

This is an intentional override of `Session.request()` to inject some error handling and retry logic. Raises: Exception: Various exceptions as defined in py:method:`raise_on_error`. Returns: Response: The response.

max_retries = (source)

Undocumented

max_retry_delay = (source)

Undocumented

Undocumented

def __handle_known_ok_response_errors(self, response: Response): (source)

Responses that report ok may also have errors. We can either log the error or raise the error as appropriate here. Args: response (Response): The response.

def __recoverable(self, response: Optional[Union[ConnectionError, Response]], url: Union[str, bytes], request_method: str, counter: int = 1): (source)

Return whether the request is recoverable and hence should be retried. Exponentially delays if recoverable. At this moment it supports: 429 Args: response (Optional[Union[ConnectionError, Response]]): The response or exception. Note: the response here is expected to be ``not response.ok``. url (Union[str, bytes]): The URL. request_method (str): The request method. counter (int, optional): The retry counter to use when calculating the exponential delay. Defaults to 1. Returns: bool: True if the request should be retried.

def _jira_prepare(self, **original_kwargs) -> dict: (source)

Do any pre-processing of our own and return the updated kwargs.