Rate limiting - kombu.utils.limits¶
Token bucket implementation for rate limiting.
Token Bucket Algorithm.
This implementation is not thread safe. Access to a TokenBucket instance should occur within the critical section of any multithreaded code.
Trueif the number of tokens can be consumed from the bucket. If they can be consumed, a call will also consume the requested number of tokens from the bucket. Calls will only consume tokens (the number requested) or zero tokens – it will never consume a partial number of tokens.
Maximum number of tokens in the bucket.
Return the time (in seconds) when a new token is expected to be available. This will not consume any tokens 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.