# Path: qarnot/exceptions.py
# class UnauthorizedException(QarnotException):
#     """Invalid token."""


import time
from .exceptions import UnauthorizedException


def with_retry(http_request_func):
    def _with_retry(self, *args, **kwargs):
        retry = self._retry_count
        last_chance = False

        while True:
            try:
                ret = http_request_func(self, *args, **kwargs)
            except ConnectionError:
                if last_chance:
                    raise

            if ret.ok:
                return ret
            if ret.status_code == 401:

# Path: qarnot/exceptions.py
# class UnauthorizedException(QarnotException):
#     """Invalid token."""


# Path: qarnot/_retry.py
import time
from .exceptions import UnauthorizedException



def with_retry(http_request_func):
    def _with_retry(self, *args, **kwargs):
        retry = self._retry_count
        last_chance = False

        while True:
            try:
                ret = http_request_func(self, *args, **kwargs)
            except ConnectionError:
                if last_chance:
                    raise

            if ret.ok:
                return ret
            if ret.status_code == 401:

                raise UnauthorizedException()