Token bucket implementation for rate limiting.
copyright: |
|
---|---|
license: | BSD, see LICENSE for more details. |
Token Bucket Algorithm.
See http://en.wikipedia.org/wiki/Token_Bucket Most of this code was stolen from an entry in the ASPN Python Cookbook: http://code.activestate.com/recipes/511490/
Thread safety
This implementation may not be thread safe.
Returns True if tokens number of tokens can be consumed from the bucket.
Maximum number of tokensin the bucket.
Returns the expected time in seconds when a new token should be available.
Warning
This consumes a token from the bucket.
The rate in tokens/second that the bucket will be refilled
Timestamp of the last time a token was taken out of the bucket.