fixed tokenbucket a bit
This commit is contained in:
parent
9ea736f6e5
commit
c76f9215c4
@ -51,8 +51,8 @@ class TokenBucket(object):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def tokens(self):
|
def tokens(self):
|
||||||
|
now = time()
|
||||||
if self._tokens < self.capacity:
|
if self._tokens < self.capacity:
|
||||||
now = time.time()
|
|
||||||
delta = self.fill_rate * (now - self.timestamp)
|
delta = self.fill_rate * (now - self.timestamp)
|
||||||
self._tokens = min(self.capacity, self._tokens + delta)
|
self._tokens = min(self.capacity, self._tokens + delta)
|
||||||
self.timestamp = now
|
self.timestamp = now
|
||||||
|
Loading…
x
Reference in New Issue
Block a user