How to use the uplink.retry function in uplink

To help you get started, we’ve selected a few uplink 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 prkumar / uplink / tests / integration / test_retry.py View on Github external
    @retry(when=retry.when.status_5xx(), backoff=backoff_default)
    @get("repos/{user}/{repo}/issues")
    def get_issues(self, user, repo):
        pass
github prkumar / uplink / tests / unit / test_retry.py View on Github external
def test_basic_client_exception(self, request_builder):
        exc = self._get_exception(retry.BASE_CLIENT_EXCEPTION, request_builder)
        assert request_builder.client.exceptions.BaseClientException == exc
github prkumar / uplink / tests / integration / test_retry.py View on Github external
    @retry(max_attempts=3, on_exception=retry.CONNECTION_TIMEOUT)
    @get("repos/{user}/{repo}/project/{project}")
    def get_project(self, user, repo, project):
        pass
github prkumar / uplink / tests / integration / test_retry.py View on Github external
import pytest_twisted

# Local imports.
from uplink import get, Consumer, retry
from uplink.clients import io
from tests import requires_python34

# Constants
BASE_URL = "https://api.github.com/"


def backoff_once():
    yield 0.1


backoff_default = retry.backoff.exponential(multiplier=0.1, minimum=0.1)


class GitHub(Consumer):
    @retry(max_attempts=2, backoff=backoff_default)
    @get("/users/{user}")
    def get_user(self, user):
        pass

    @retry(max_attempts=3, backoff=backoff_once)
    @get("repos/{user}/{repo}/issues/{issue}")
    def get_issue(self, user, repo, issue):
        pass

    @retry(max_attempts=3, on_exception=retry.CONNECTION_TIMEOUT)
    @get("repos/{user}/{repo}/project/{project}")
    def get_project(self, user, repo, project):
github prkumar / uplink / tests / unit / test_retry.py View on Github external
def test_retry_backoff():
    def custom_backoff(*_):
        return True

    decorator = retry(backoff=custom_backoff)
    assert decorator._backoff == custom_backoff
github prkumar / uplink / tests / unit / test_retry.py View on Github external
def test_connection_error(self, request_builder):
        exc = self._get_exception(retry.CONNECTION_ERROR, request_builder)
        assert request_builder.client.exceptions.BaseClientException == exc
github prkumar / uplink / tests / integration / test_retry.py View on Github external
    @retry(max_attempts=3, backoff=backoff_once)
    @get("repos/{user}/{repo}/issues/{issue}")
    def get_issue(self, user, repo, issue):
        pass
github prkumar / uplink / tests / unit / test_retry.py View on Github external
def test_ssl_error(self, request_builder):
        exc = self._get_exception(retry.SSL_ERROR, request_builder)
        assert request_builder.client.exceptions.BaseClientException == exc
github prkumar / uplink / tests / unit / test_retry.py View on Github external
def test_connection_timeout(self, request_builder):
        exc = self._get_exception(retry.CONNECTION_TIMEOUT, request_builder)
        assert request_builder.client.exceptions.BaseClientException == exc
github prkumar / uplink / tests / unit / test_retry.py View on Github external
def test_server_timeout(self, request_builder):
        exc = self._get_exception(retry.SERVER_TIMEOUT, request_builder)
        assert request_builder.client.exceptions.BaseClientException == exc