ratelimiter
ratelimiter copied to clipboard
Broken algorithm
The algorithm will always wait too much.
import time
from ratelimiter import RateLimiter
rate_limiter = RateLimiter(max_calls=1, period=1)
start = time.time()
for i in range(3):
with rate_limiter:
print("%.02f" % (time.time() - start))
time.sleep(1)
outputs
0.00
2.00
4.01
I would expect it to output 0 1 2