@classmethod
def refresh_token_if_needed(cls, decorated):
    "\n        This decorator checks if the current client's access token is about to\n        be expired/already expired, and if so, updates to a new one.\n        "

    @wraps(decorated)
    def inner(*args, **kwargs):
        api_key = args[0]._api_key
        if (not is_authenticated(api_key)):
            get_logger().warn("Mona's client is not authenticated")
            return False
        if _should_refresh_token(api_key):
            with authentication_lock:
                if _should_refresh_token(api_key):
                    did_refresh_token = _refresh_token(api_key)
                    if (not did_refresh_token):
                        return False
        return decorated(*args, **kwargs)
    return inner
This decorator checks if the current client's access token is about to
be expired/already expired, and if so, updates to a new one.
@classmethod
def refresh_token_if_needed(cls, decorated):
    "\n        This decorator checks if the current client's access token is about to\n        be expired/already expired, and if so, updates to a new one.\n        "

    @wraps(decorated)
    def inner(*args, **kwargs):
        api_key = args[0]._api_key
        if (not is_authenticated(api_key)):
            get_logger().warn("Mona's client is not authenticated")
            return False
        if _should_refresh_token(api_key):
            with authentication_lock:
                if _should_refresh_token(api_key):
                    did_refresh_token = _refresh_token(api_key)
                    if (not did_refresh_token):
                        return False
        return decorated(*args, **kwargs)
    return inner