MCPcopy Index your code
hub / github.com/Tong89/smartNode / check

Method check

backend/ratelimit.py:21–33  ·  view source on GitHub ↗

返回 (allowed, remaining, retry_after_seconds)。

(self, key, limit, window)

Source from the content-addressed store, hash-verified

19 self._lock = threading.Lock()
20
21 def check(self, key, limit, window):
22 """返回 (allowed, remaining, retry_after_seconds)。"""
23 now = time.time()
24 cutoff = now - window
25 with self._lock:
26 q = self._hits.setdefault(key, [])
27 while q and q[0] < cutoff:
28 q.pop(0)
29 if len(q) >= limit:
30 retry = window - (now - q[0])
31 return False, 0, max(0.0, retry)
32 q.append(now)
33 return True, limit - len(q), 0.0
34
35
36_limiter = SlidingWindowLimiter()

Callers 2

wrapperFunction · 0.45
_check_beam_pointingMethod · 0.45

Calls 1

appendMethod · 0.80

Tested by

no test coverage detected