diff options
Diffstat (limited to 'kombu/utils/limits.py')
-rw-r--r-- | kombu/utils/limits.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/kombu/utils/limits.py b/kombu/utils/limits.py index 36d11f1f..413c6c62 100644 --- a/kombu/utils/limits.py +++ b/kombu/utils/limits.py @@ -11,13 +11,15 @@ __all__ = ('TokenBucket',) class TokenBucket: """Token Bucket Algorithm. - See Also: + See Also + -------- https://en.wikipedia.org/wiki/Token_Bucket Most of this code was stolen from an entry in the ASPN Python Cookbook: https://code.activestate.com/recipes/511490/ Warning: + ------- Thread Safety: This implementation is not thread safe. Access to a `TokenBucket` instance should occur within the critical section of any multithreaded code. @@ -51,7 +53,8 @@ class TokenBucket: def can_consume(self, tokens=1): """Check if one or more tokens can be consumed. - Returns: + Returns + ------- bool: true if 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. @@ -67,7 +70,8 @@ class TokenBucket: def expected_time(self, tokens=1): """Return estimated time of token availability. - Returns: + Returns + ------- float: the time in seconds. """ _tokens = self._get_tokens() |