MCPcopy Create free account
hub / github.com/AgentOps-AI/agentops / is_blocked

Function is_blocked

app/api/agentops/common/rate_limit.py:36–48  ·  view source on GitHub ↗

Check if the IP address is rate-limited. Returns True if the number of recent requests exceeds RATE_LIMIT_COUNT. Always returns False if RATE_LIMIT_ENABLE is False.

(ip: str)

Source from the content-addressed store, hash-verified

34
35
36def is_blocked(ip: str) -> bool:
37 """
38 Check if the IP address is rate-limited.
39 Returns True if the number of recent requests exceeds RATE_LIMIT_COUNT.
40 Always returns False if RATE_LIMIT_ENABLE is False.
41 """
42 if not RATE_LIMIT_ENABLE:
43 return False
44
45 key, now = _key(ip), _now_us()
46
47 count = cache.zcount(key, now - WINDOW_US, now)
48 return count > RATE_LIMIT_COUNT
49
50
51def clear(ip: str) -> None:

Callers

nothing calls this directly

Calls 3

_keyFunction · 0.85
_now_usFunction · 0.85
zcountMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…