Browse Source

fixed tokenbucket a bit

master
jcao219 14 years ago
parent
commit
b9d0576aa3
  1. 4
      oyoyo/client.py

4
oyoyo/client.py

@ -51,11 +51,11 @@ class TokenBucket(object): @@ -51,11 +51,11 @@ class TokenBucket(object):
@property
def tokens(self):
now = time()
if self._tokens < self.capacity:
now = time.time()
delta = self.fill_rate * (now - self.timestamp)
self._tokens = min(self.capacity, self._tokens + delta)
self.timestamp = now
self.timestamp = now
return self._tokens

Loading…
Cancel
Save