How to use the tenacity.wait_incrementing function in tenacity

To help you get started, we’ve selected a few tenacity 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 jd / tenacity / test_tenacity.py View on Github external
def test_incrementing_sleep(self):
        r = Retrying(wait=tenacity.wait_incrementing(
            start=500, increment=100))
        self.assertEqual(500, r.wait(1, 6546))
        self.assertEqual(600, r.wait(2, 6546))
        self.assertEqual(700, r.wait(3, 6546))
github openstack / octavia / octavia / controller / worker / v2 / controller_worker.py View on Github external
        wait=tenacity.wait_incrementing(
            RETRY_INITIAL_DELAY, RETRY_BACKOFF, RETRY_MAX),
        stop=tenacity.stop_after_attempt(RETRY_ATTEMPTS))
    def create_load_balancer(self, loadbalancer, flavor=None,
                             availability_zone=None):
        """Creates a load balancer by allocating Amphorae.

        First tries to allocate an existing Amphora in READY state.
        If none are available it will attempt to build one specifically
        for this load balancer.

        :param loadbalancer: The dict of load balancer to create
        :returns: None
        :raises NoResultFound: Unable to find the object
        """
        lb = self._lb_repo.get(db_apis.get_session(),
                               id=loadbalancer[constants.LOADBALANCER_ID])
github openstack / mistral / mistral / utils / rest_utils.py View on Github external
def create_db_retry_object():
    return MistralRetrying(
        retry=tenacity.retry_if_exception_type(
            (
                sa.exc.OperationalError,
                db_exc.DBDeadlock,
                db_exc.DBConnectionError
            )
        ),
        stop=tenacity.stop_after_attempt(10),
        wait=tenacity.wait_incrementing(increment=0.5)  # 0.5 seconds
    )
github openstack / senlin / senlin / engine / notifications / message.py View on Github external
        wait=tenacity.wait_incrementing(
            RETRY_INITIAL_DELAY, RETRY_BACKOFF, RETRY_MAX),
        stop=tenacity.stop_after_attempt(RETRY_ATTEMPTS))
    def post_lifecycle_hook_message(self, lifecycle_action_token, node_id,
                                    resource_id, lifecycle_transition_type):
        message_list = [{
            "ttl": CONF.notification.ttl,
            "body": {
                "lifecycle_action_token": lifecycle_action_token,
                "node_id": node_id,
                "resource_id": resource_id,
                "lifecycle_transition_type": lifecycle_transition_type
            }
        }]
        try:
            if not self.zaqar().queue_exists(self.queue_name):
                kwargs = {
github mozilla / code-review / bot / code_review_bot / revisions.py View on Github external
    wait=tenacity.wait_incrementing(start=5, increment=4),
    stop=tenacity.stop_after_attempt(5),
    retry=tenacity.retry_if_exception_type(RequestException),
)
def hgmo_build_phid(repository, revision):
    """
    Retrieve the Phabricator build PHID from a try_task_config.json
    file on a remote mercurial repository on HGMO
    """
    resp = requests.get(f"{repository}/raw-file/{revision}/try_task_config.json")
    resp.raise_for_status()
    config = resp.json()

    assert config.get("version") == 2, "Invalid try task config version"
    parameters = config.get("parameters")
    assert parameters is not None, "Missing parameters"
    if "phabricator_diff" in parameters:
github openstack / octavia / octavia / controller / worker / v1 / controller_worker.py View on Github external
        wait=tenacity.wait_incrementing(
            CONF.haproxy_amphora.api_db_commit_retry_initial_delay,
            CONF.haproxy_amphora.api_db_commit_retry_backoff,
            CONF.haproxy_amphora.api_db_commit_retry_max),
        stop=tenacity.stop_after_attempt(
            CONF.haproxy_amphora.api_db_commit_retry_attempts))
    def _get_db_obj_until_pending_update(self, repo, id):

        return repo.get(db_apis.get_session(), id=id)
github openstack / octavia / octavia / controller / worker / v2 / controller_worker.py View on Github external
        wait=tenacity.wait_incrementing(
            RETRY_INITIAL_DELAY, RETRY_BACKOFF, RETRY_MAX),
        stop=tenacity.stop_after_attempt(RETRY_ATTEMPTS))
    def _get_db_obj_until_pending_update(self, repo, id):

        return repo.get(db_apis.get_session(), id=id)