Checks if we need to break moderation in order to maintain our desired
        throttle limit

        @return: True if we need to break moderation
352389
def check_elastic(self):
        '''
        
        '''
        if self.elastic and self.elastic_kick_in == self.limit:
            value = self.redis_conn.zcard(self.window_key)
            if self.limit - value > self.elastic_buffer:
                return True
        return False
912580
def is_enabled(self):
        
        if self.name in settings.exclude_rules:
            return False
        elif self.name in settings.rules:
            return True
        elif self.enabled_by_default and ALL_ENABLED in settings.rules:
            return True
        else:
            return False
1297396
def register(self, model_or_iterable, moderation_class):
        
        if isinstance(model_or_iterable, ModelBase):
            model_or_iterable = [model_or_iterable]
        for model in model_or_iterable:
            if model in self._registry:
                raise AlreadyModerated(
                    "The model '%s' is already being moderated" % model._meta.verbose_name
                )
            self._registry[model] = moderation_class(model)
273377
def _need_stop(self):
        
        if not self.option.cursor_end_time:
            return False

        all_finish = True
        for shard, consumer in self.shard_consumers.items():
            if consumer.is_shutdown():
                continue

            # has not yet do any successful fetch yet or get some data
            if consumer.last_success_fetch_time == 0 or consumer.last_fetch_count > 0:
                return False

        # init self.last_owned_consumer_finish_time if it's None
        if all_finish and self.last_owned_consumer_finish_time == 0:
            self.last_owned_consumer_finish_time = time.time()

        if abs(time.time() - self.last_owned_consumer_finish_time) >= \
                self.option.consumer_group_time_out + self.option.heartbeat_interval:
            return True

        return False
1021937
def is_exhausted(self):
        
        retry_counts = (self.total, self.connect, self.read, self.redirect, self.status)
        retry_counts = list(filter(None, retry_counts))
        if not retry_counts:
            return False

        return min(retry_counts) < 0
1097062
def _past_limit(self):
        """"""
        if self._max_episode_steps is not None and self._max_episode_steps <= self._elapsed_steps:
            logger.debug("Env has passed the step limit defined by TimeLimit.")
            return True

        if self._max_episode_seconds is not None and self._max_episode_seconds <= self._elapsed_seconds:
            logger.debug("Env has passed the seconds limit defined by TimeLimit.")
            return True

        return False
65705
protected boolean throttleRequest(final HttpServletRequest request, final HttpServletResponse response) {
        return configurationContext.getThrottledRequestExecutor() != null
            && configurationContext.getThrottledRequestExecutor().throttle(request, response);
    }
40584
def clean_limit(self):
        ""
        limit = self.cleaned_data.get('limit', None)
        if (settings.SELECTABLE_MAX_LIMIT is not None and
            (not limit or limit > settings.SELECTABLE_MAX_LIMIT)):
            limit = settings.SELECTABLE_MAX_LIMIT
        return limit
194674
def rate_limit(self):
        
        rate_limited_msg = False

        while True:
            is_rate_limited = self.limit.is_rate_limited(uuid)
            if is_rate_limited:
                time.sleep(0.3)  # save hammering redis
                if not rate_limited_msg:
                    self.logger.info('Rate limit active..please wait...')
                    rate_limited_msg = True

            if not is_rate_limited:
                self.logger.info('Rate limit clear.')
                self.limit.attempt(uuid)
                return True
33943
def throttle_check(self):
        
        throttle = self._meta.throttle()
        wait = throttle.should_be_throttled(self)
        if wait:
            raise HttpError(
                "Throttled, wait {0} seconds.".format(wait),
                status=status.HTTP_503_SERVICE_UNAVAILABLE)
784880
def is_forced_retry(self, method, status_code):
        
        if self.method_whitelist and method.upper() not in self.method_whitelist:
            return False

        return self.status_forcelist and status_code in self.status_forcelist
899293
def has_moderator_permissions(self, request):
        
        return any(request.user.has_perm(perm) for perm in self.permission_required)
289521
def failed_login_limit_reached(self):
        
        login_limit = 10
        if self.failed_logins and self.failed_logins >= login_limit:
            return True
        else:
            return False
73165
protected boolean maxRequestsServed() {
        // PK12235, check for a partial or full stop
        if (getChannel().isStopping()) {
            // channel has stopped, no more keep-alives
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Channel stopped, disabling keep-alive request");
            }
            return true;
        }
        if (!getChannel().getHttpConfig().isKeepAliveEnabled()) {
            // keep alives are disabled, no need to check the max request number
            return true;
        }
        int max = getChannel().getHttpConfig().getMaximumPersistentRequests();
        // -1 is unlimited, 0..1 is 1 request, any above that is that exact
        // number of requests
        if (0 <= max) {
            return (this.numRequestsProcessed >= max);
        }
        return false;
    }
315279
def comments_are_moderated(content_object):
    
    moderator = get_model_moderator(content_object.__class__)
    if moderator is None:
        return False

    # Check the 'auto_moderate_field', 'moderate_after',
    # by reusing the basic Django policies.
    return CommentModerator.moderate(moderator, None, content_object, None)
512468
public function throttle()
    {
        if ((time() - $this->lastCpuCheck) >= $this->cpuCheckFrequency) {
            $load = sys_getloadavg();
            
            if ($load[0]/$this->cpuCount >= $this->cpuTarget) {
                $this->pause += $this->throttleSensitivity;
                $this->controller->notify('Daemon throttling down');
            } else {
                $this->pause -= $this->throttleSensitivity;
                $this->controller->notify('Daemon throttling up');
            }

            $this->lastCpuCheck = time();
        }

        // Never allow pause to dip below 1 microsecond
        if ($this->pause < 1) {
            $this->pause = 1;
        }

        return $this->pause;
    }
758954
boolean forceDefrag() {

        long megas = properties.getIntegerProperty(
            HsqlDatabaseProperties.hsqldb_defrag_limit, 200);
        long defraglimit = megas * 1024L * 1024;
        long lostSize    = cache.freeBlocks.getLostBlocksSize();

        return lostSize > defraglimit;
    }