We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c35d0bc commit c9e8267Copy full SHA for c9e8267
ratelimit.py
@@ -25,14 +25,14 @@ async def wrapper(*args, **kwargs):
25
if req is None:
26
req = kwargs.get("request", None)
27
28
- # If no request found, just call the function
+ # If no request found (e.g., in tests or direct function calls), execute without rate limiting
29
30
if inspect.iscoroutinefunction(func):
31
return await func(*args, **kwargs)
32
else:
33
return func(*args, **kwargs)
34
35
- # Rate limiting logic
+ # Apply rate limiting: check window, count requests, and enforce limits
36
now = time.time()
37
k = _key(req)
38
window_start, count = _STORE.get(k, (now, 0))
0 commit comments