Go to the latest version of this document.
search in docstrings

Search bar offers the following options:

- Term presence. The below example searches for documents that must contain “foo”, might contain “bar” and must not contain “baz”: `+foo bar -baz`
- Wildcards. The below example searches for documents with words beginning with “foo”: `foo*`
- Search in specific fields. The following search matches all objects in "twisted.mail" that matches “search”: `+qname:twisted.mail.* +search`

  Possible fields: 'name', 'qname' (fully qualified name), 'docstring', and 'kind'. Last two fields are only applicable if "search in docstrings" is enabled.

- Fuzzy matches. The following search matches all documents that have a word within 1 edit distance of “foo”: `foo~1`

Results provided by Lunr.js

# ``twisted`.`protocols`.`htb`.`Bucket``

class documentation

`class Bucket: (source)`

View In Hierarchy

Implementation of a Token bucket.

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

Method | `__init__` | Create a `Bucket` that may have a parent `Bucket`.
Method | `add` | Adds tokens to the `Bucket` and its `parentBucket`.
Method | `drip` | Let some of the bucket drain.
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.
Instance Variable | `content` | Undocumented
Instance Variable | `lastDrip` | Undocumented
Instance Variable | `parentBucket` | Undocumented
Class Variable | `_refcount` | Undocumented

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

Create a `Bucket` that may have a parent `Bucket`.

Parameters
parentBucket:`Bucket` | If a parent Bucket is specified, all `add` and `drip` operations on this `Bucket` will be applied on the parent `Bucket` as well.

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`.

Parameters
amount:`int` | The number of tokens to try to add.
Returns
`int` | The number of tokens that actually fit.

def drip(self): (source)

Let some of the bucket drain.

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

Returns
`bool` | `True` if the bucket is empty after this drip.

maxburst: `int` = (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.

rate: `int` = (source)

The rate at which the bucket drains, in number of tokens per second. If the rate is `None`, the bucket drains instantaneously.

content: `int` = (source)

Undocumented

lastDrip = (source)

Undocumented

parentBucket = (source)

Undocumented

_refcount: `int` = (source)

Undocumented