def is_retriable_exception()

in pyqldb/errors/__init__.py [0:0]


def is_retriable_exception(e):
    """
    Is the exception a retryable exception?

    :type e: :py:class:`builtins.Exception`
    :param e: The Exception caught.

    :rtype: bool
    :return: True if the exception is a retryable exception. False otherwise.
    """

    is_retryable = (isinstance(e, ClientError) and (e.response['ResponseMetadata']['HTTPStatusCode'] == 500 or
                                                    e.response['ResponseMetadata']['HTTPStatusCode'] == 503 or
                                                    e.response['Error']['Code'] == 'NoHttpResponseException' or
                                                    e.response['Error']['Code'] == 'SocketTimeoutException')) or \
                   isinstance(e, RETRYABLE_HTTP_ERRORS) or \
                   is_occ_conflict_exception(e) or \
                   (is_invalid_session_exception(e) and not is_transaction_expired_exception(e))
    return is_retryable