How to use the aliyun-python-sdk-core.alibabacloud.retry.retry_condition.RetryCondition function in aliyun-python-sdk-core

To help you get started, we’ve selected a few aliyun-python-sdk-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aliyun / aliyun-openapi-python-sdk / aliyun-python-sdk-core / alibabacloud / retry / retry_condition.py View on Github external
def should_retry(self, retry_policy_context):
        retryable = RetryCondition.BLANK_STATUS
        no_retry_flag = RetryCondition.NO_RETRY
        mask = RetryCondition.SHOULD_RETRY
        mask |= RetryCondition.SHOULD_RETRY_WITH_CLIENT_TOKEN
        mask |= RetryCondition.SHOULD_RETRY_WITH_THROTTLING_BACKOFF

        for condition in self.conditions:
            ret = condition.should_retry(retry_policy_context)
            retryable |= ret & mask
            no_retry_flag &= ret & RetryCondition.NO_RETRY
        return retryable | no_retry_flag
github aliyun / aliyun-openapi-python-sdk / aliyun-python-sdk-core / alibabacloud / retry / retry_condition.py View on Github external
def should_retry(self, retry_policy_context):
        retryable = RetryCondition.BLANK_STATUS
        no_retry_flag = RetryCondition.NO_RETRY
        mask = RetryCondition.SHOULD_RETRY
        mask |= RetryCondition.SHOULD_RETRY_WITH_CLIENT_TOKEN
        mask |= RetryCondition.SHOULD_RETRY_WITH_THROTTLING_BACKOFF

        for condition in self.conditions:
            ret = condition.should_retry(retry_policy_context)
            retryable |= ret & mask
            no_retry_flag &= ret & RetryCondition.NO_RETRY
        return retryable | no_retry_flag
github aliyun / aliyun-openapi-python-sdk / aliyun-python-sdk-core / alibabacloud / retry / retry_condition.py View on Github external
def __init__(self, retry_config):
        self.retry_config = retry_config

    def should_retry(self, retry_policy_context):
        request = retry_policy_context.original_request
        retry_config_prefix = retry_policy_context.retry_config_prefix
        retryable_apis = _find_data_in_retry_config(
            "RetryableAPIsWithClientToken", retry_config_prefix, self.retry_config)
        if isinstance(retryable_apis, list) and request.action_name in retryable_apis:
            return RetryCondition.SHOULD_RETRY | RetryCondition.SHOULD_RETRY_WITH_THROTTLING_BACKOFF
        else:
            return RetryCondition.NO_RETRY


class AndRetryCondition(RetryCondition):

    def __init__(self, conditions):
        self.conditions = conditions

    def should_retry(self, retry_policy_context):
        retryable = RetryCondition.BLANK_STATUS
        for condition in self.conditions:
            retryable |= condition.should_retry(retry_policy_context)
        return retryable


class OrRetryCondition(RetryCondition):

    def __init__(self, conditions):
        self.conditions = conditions
github aliyun / aliyun-openapi-python-sdk / aliyun-python-sdk-core / alibabacloud / retry / retry_condition.py View on Github external
def __init__(self, max_retry_times, retry_config):
        RetryCondition.__init__(self)
        self._inner_condition = AndRetryCondition([
            MaxRetryTimesCondition(max_retry_times),
            OrRetryCondition([
                RetryOnApiCondition(retry_config),
                RetryOnApiWithClientTokenCondition(retry_config),
            ]),
            OrRetryCondition([
                RetryOnExceptionCondition(retry_config),
                RetryOnHttpStatusCondition(),
            ]),
github aliyun / aliyun-openapi-python-sdk / aliyun-python-sdk-core / alibabacloud / retry / retry_condition.py View on Github external
def should_retry(self, retry_policy_context):
        retryable = RetryCondition.BLANK_STATUS
        for condition in self.conditions:
            retryable |= condition.should_retry(retry_policy_context)
        return retryable
github aliyun / aliyun-openapi-python-sdk / aliyun-python-sdk-core / alibabacloud / retry / retry_condition.py View on Github external
def should_retry(self, retry_policy_context):
        retryable = RetryCondition.BLANK_STATUS
        no_retry_flag = RetryCondition.NO_RETRY
        mask = RetryCondition.SHOULD_RETRY
        mask |= RetryCondition.SHOULD_RETRY_WITH_CLIENT_TOKEN
        mask |= RetryCondition.SHOULD_RETRY_WITH_THROTTLING_BACKOFF

        for condition in self.conditions:
            ret = condition.should_retry(retry_policy_context)
            retryable |= ret & mask
            no_retry_flag &= ret & RetryCondition.NO_RETRY
        return retryable | no_retry_flag
github aliyun / aliyun-openapi-python-sdk / aliyun-python-sdk-core / alibabacloud / retry / retry_condition.py View on Github external
if retryable_http_status_list:
            self.retryable_http_status_list = retryable_http_status_list
        else:
            self.retryable_http_status_list = self.DEFAULT_RETRYABLE_HTTP_STATUS_LIST

    def should_retry(self, retry_policy_context):
        if retry_policy_context.http_status_code in self.retryable_http_status_list:
            logger.debug(
                "Retryable HTTP error occurred. HTTP status code: %s",
                retry_policy_context.http_status_code)
            return RetryCondition.SHOULD_RETRY
        else:
            return RetryCondition.NO_RETRY


class RetryOnApiCondition(RetryCondition):

    def __init__(self, retry_config):
        self.retry_config = retry_config

    def should_retry(self, retry_policy_context):
        request = retry_policy_context.original_request
        retryable_apis = _find_data_in_retry_config("RetryableAPIs", request, self.retry_config)
        if isinstance(retryable_apis, list) and request.get_action_name() in retryable_apis:
            return RetryCondition.SHOULD_RETRY
        else:
            return RetryCondition.NO_RETRY


class RetryOnApiWithClientTokenCondition(RetryCondition):

    def __init__(self, retry_config):
github aliyun / aliyun-openapi-python-sdk / aliyun-python-sdk-core / alibabacloud / retry / retry_condition.py View on Github external
class RetryCondition(object):

    BLANK_STATUS = 0
    NO_RETRY = 1
    SHOULD_RETRY = 2
    SHOULD_RETRY_WITH_CLIENT_TOKEN = 4
    SHOULD_RETRY_WITH_THROTTLING_BACKOFF = 8

    def should_retry(self, retry_policy_context):
        """Decide whether the previous request should be retried."""
        pass


class NoRetryCondition(RetryCondition):

    def should_retry(self, retry_policy_context):
        return RetryCondition.NO_RETRY


class MaxRetryTimesCondition(RetryCondition):

    def __init__(self, max_retry_times):
        validation.assert_integer_positive(max_retry_times, "max_retry_times")
        self.max_retry_times = max_retry_times

    def should_retry(self, retry_policy_context):

        if retry_policy_context.retries_attempted < self.max_retry_times:
            return RetryCondition.SHOULD_RETRY
        else:
github aliyun / aliyun-openapi-python-sdk / aliyun-python-sdk-core / alibabacloud / retry / retry_condition.py View on Github external
SHOULD_RETRY = 2
    SHOULD_RETRY_WITH_CLIENT_TOKEN = 4
    SHOULD_RETRY_WITH_THROTTLING_BACKOFF = 8

    def should_retry(self, retry_policy_context):
        """Decide whether the previous request should be retried."""
        pass


class NoRetryCondition(RetryCondition):

    def should_retry(self, retry_policy_context):
        return RetryCondition.NO_RETRY


class MaxRetryTimesCondition(RetryCondition):

    def __init__(self, max_retry_times):
        validation.assert_integer_positive(max_retry_times, "max_retry_times")
        self.max_retry_times = max_retry_times

    def should_retry(self, retry_policy_context):

        if retry_policy_context.retries_attempted < self.max_retry_times:
            return RetryCondition.SHOULD_RETRY
        else:
            logger.debug("Reached the maximum number of retry. Attempts:%d",
                         retry_policy_context.retries_attempted)
            return RetryCondition.NO_RETRY


class RetryOnExceptionCondition(RetryCondition):
github aliyun / aliyun-openapi-python-sdk / aliyun-python-sdk-core / alibabacloud / retry / retry_condition.py View on Github external
def should_retry(self, retry_policy_context):
        retryable = RetryCondition.BLANK_STATUS
        no_retry_flag = RetryCondition.NO_RETRY
        mask = RetryCondition.SHOULD_RETRY
        mask |= RetryCondition.SHOULD_RETRY_WITH_CLIENT_TOKEN
        mask |= RetryCondition.SHOULD_RETRY_WITH_THROTTLING_BACKOFF

        for condition in self.conditions:
            ret = condition.should_retry(retry_policy_context)
            retryable |= ret & mask
            no_retry_flag &= ret & RetryCondition.NO_RETRY
        return retryable | no_retry_flag


class MixedRetryCondition(RetryCondition):

    def __init__(self, max_retry_times, retry_config):
        RetryCondition.__init__(self)
        self._inner_condition = AndRetryCondition([
            MaxRetryTimesCondition(max_retry_times),
            OrRetryCondition([
                RetryOnApiCondition(retry_config),
                RetryOnApiWithClientTokenCondition(retry_config),
            ]),
            OrRetryCondition([
                RetryOnExceptionCondition(retry_config),
                RetryOnHttpStatusCondition(),
            ]),
        ])

    def should_retry(self, retry_policy_context):

aliyun-python-sdk-core

The core module of Aliyun Python SDK.

Apache-2.0
Latest version published 1 month ago

Package Health Score

82 / 100
Full package analysis

Popular aliyun-python-sdk-core functions

Similar packages