Implement a rate limiter as a Python module ratelimit that enforces a sliding-window token-bucket policy…
Implement a rate limiter as a Python module ratelimit that enforces a sliding-window token-bucket policy…: a task in TermGrade Environments: 1,004 executable Linux tasks (Harbor dataset). Semantics: - Each key has a bucket that can hold at most capacity tokens (default 10). - Initially the bucket…
The task
**Semantics:** - Each key has a bucket that can hold at most `capacity` tokens (default 10). - Initially the bucket is full. - Tokens refill at a constant rate of `refill_rate` tokens per second (default 2.0). Refill is continuous and must be computed precisely at the moment of each call based on elapsed time since…
Part of ai-and/termgrade-environments.