ratelimiter icon indicating copy to clipboard operation
ratelimiter copied to clipboard

Broken algorithm

Open louisabraham opened this issue 1 year ago • 3 comments

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

louisabraham avatar Aug 25 '22 20:08 louisabraham