class documentation

class twisted.protocols.htb.Bucket: (source)

View In Hierarchy

Implementation of a Token bucket.

A bucket can hold a certain number of tokens and it drains over time.

Class Variable maxburst The maximum number of tokens that the bucket can hold at any given time. If this is None, the bucket has an infinite size.
Class Variable rate The rate at which the bucket drains, in number of tokens per second. If the rate is None, the bucket drains instantaneously.
Method __init__ Create a Bucket that may have a parent Bucket.
Instance Variable content Undocumented
Instance Variable parentBucket Undocumented
Instance Variable lastDrip Undocumented
Method add Adds tokens to the Bucket and its parentBucket.
Method drip Let some of the bucket drain.
Class Variable _refcount Undocumented
maxburst = (source)
The maximum number of tokens that the bucket can hold at any given time. If this is None, the bucket has an infinite size.
(type: int)
rate = (source)
The rate at which the bucket drains, in number of tokens per second. If the rate is None, the bucket drains instantaneously.
(type: int)
_refcount = (source)

Undocumented

(type: int)
def __init__(self, parentBucket=None): (source)

Create a Bucket that may have a parent Bucket.

ParametersparentBucketIf a parent Bucket is specified, all add and drip operations on this Bucket will be applied on the parent Bucket as well. (type: Bucket)
content = (source)

Undocumented

parentBucket = (source)

Undocumented

lastDrip = (source)

Undocumented

def add(self, amount): (source)

Adds tokens to the Bucket and its parentBucket.

This will add as many of the amount tokens as will fit into both this Bucket and its parentBucket.

ParametersamountThe number of tokens to try to add. (type: int)
ReturnsThe number of tokens that actually fit. (type: int)
def drip(self): (source)

Let some of the bucket drain.

The Bucket drains at the rate specified by the class variable rate.

ReturnsTrue if the bucket is empty after this drip. (type: bool)
API Documentation for Twisted, generated by pydoctor 20.12.1 at 2021-02-28 19:53:36.