How to use the evasdk.eva_errors.EvaAutoRenewError function in evasdk

To help you get started, we’ve selected a few evasdk 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 automata-tech / eva_python_sdk / evasdk / eva_http_client.py View on Github external
def api_call_with_auth(self, *args, **kwargs):

        r = self.__api_request(*args, **kwargs)

        # Try creating a new session if we get an auth error and retrying the failed request
        if r.status_code == 401:
            self.__logger.debug('Creating a new session and retrying failed request')
            self.auth_create_session()
            return self.__api_request(*args, **kwargs)

        if self.renew_period < time.time() - self.__last_renew < 30 * 60:
            self.__logger.debug('Automatically renewing session')
            try:
                self.auth_renew_session()
            except EvaError as e:
                raise EvaAutoRenewError('Failed to automatically renew, got error {}'.format(str(e)))

        return r