From e426c25ddd02162654a21ee06277e64be5485f5a Mon Sep 17 00:00:00 2001 From: Ryan Schmidt Date: Fri, 13 Jul 2018 21:45:25 -0700 Subject: [PATCH] Change oyoyo tokenbucket to be consistent with !wait TB In !wait, the delay is how long it takes (in seconds) to add one token, whereas in oyoyo the delay was the opposite (lower = longer refill). IMO the !wait one makes more sense, so change oyoyo to match. --- oyoyo/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oyoyo/client.py b/oyoyo/client.py index 11de7d2..9beba0e 100644 --- a/oyoyo/client.py +++ b/oyoyo/client.py @@ -58,7 +58,7 @@ class TokenBucket(object): def tokens(self): now = time.time() if self._tokens < self.capacity: - delta = self.fill_rate * (now - self.timestamp) + delta = (now - self.timestamp) / self.fill_rate self._tokens = min(self.capacity, self._tokens + delta) self.timestamp = now return self._tokens