perceval/backends/core/github.py
def _need_check_tokens(self):
        """Check if we need to switch GitHub API tokens"""

        if self.n_tokens <= 1 or self.rate_limit is None:
            return False
        elif self.last_rate_limit_checked is None:
            self.last_rate_limit_checked = self.rate_limit
            return True

        # If approaching minimum rate limit for sleep
        approaching_limit = float(self.min_rate_to_sleep) * (1.0 + TOKEN_USAGE_BEFORE_SWITCH) + 1
        if self.rate_limit <= approaching_limit:
            self.last_rate_limit_checked = self.rate_limit
            return True

        # Only switch token when used predefined factor of the current token's remaining API points
        ratio = float(self.rate_limit) / float(self.last_rate_limit_checked)
        if ratio < 1.0 - TOKEN_USAGE_BEFORE_SWITCH:
            self.last_rate_limit_checked = self.rate_limit
            return True
        elif ratio > 1.0:
            self.last_rate_limit_checked = self.rate_limit
            return False
        else:
            return False
def _need_check_tokens(self):
        if self.n_tokens <= 1 or self.rate_limit is None:
            return False
        elif self.last_rate_limit_checked is None:
            self.last_rate_limit_checked = self.rate_limit
            return True

        # If approaching minimum rate limit for sleep
        approaching_limit = float(self.min_rate_to_sleep) * (1.0 + TOKEN_USAGE_BEFORE_SWITCH) + 1
        if self.rate_limit <= approaching_limit:
            self.last_rate_limit_checked = self.rate_limit
            return True

        # Only switch token when used predefined factor of the current token's remaining API points
        ratio = float(self.rate_limit) / float(self.last_rate_limit_checked)
        if ratio < 1.0 - TOKEN_USAGE_BEFORE_SWITCH:
            self.last_rate_limit_checked = self.rate_limit
            return True
        elif ratio > 1.0:
            self.last_rate_limit_checked = self.rate_limit
            return False
        else:
            return False
def _need_check_tokens ( self ) : if self . n_tokens <= 1 or self . rate_limit is None : return False elif self . last_rate_limit_checked is None : self . last_rate_limit_checked = self . rate_limit return True # If approaching minimum rate limit for sleep approaching_limit = float ( self . min_rate_to_sleep ) * ( 1.0 + TOKEN_USAGE_BEFORE_SWITCH ) + 1 if self . rate_limit <= approaching_limit : self . last_rate_limit_checked = self . rate_limit return True # Only switch token when used predefined factor of the current token's remaining API points ratio = float ( self . rate_limit ) / float ( self . last_rate_limit_checked ) if ratio < 1.0 - TOKEN_USAGE_BEFORE_SWITCH : self . last_rate_limit_checked = self . rate_limit return True elif ratio > 1.0 : self . last_rate_limit_checked = self . rate_limit return False else : return False
Check if we need to switch GitHub API tokens
Check if we need to switch GitHub API tokens