pytokenbucket package

Submodules

pytokenbucket.tokenbucket module

Implementation of a thread-safe token bucket using threads and queues.

class pytokenbucket.tokenbucket.TokenBucket(bucket_size=10, refresh_amount=1, refresh_period_ms=1000, start_filled=True)[source]

Bases: object

A token bucket. Tokens can be requested using get_token.

deferred_call(callable)[source]

Return a callable which calls the argument when a token is available.

get_token()[source]

Get a token. Blocks until a token is retrieved or the token bucket is stopped.

stop()[source]

Stop the token bucket pending a shutdown.

Module contents

Top-level package for Python Token Bucket.

class pytokenbucket.TokenBucket(bucket_size=10, refresh_amount=1, refresh_period_ms=1000, start_filled=True)[source]

Bases: object

A token bucket. Tokens can be requested using get_token.

deferred_call(callable)[source]

Return a callable which calls the argument when a token is available.

get_token()[source]

Get a token. Blocks until a token is retrieved or the token bucket is stopped.

stop()[source]

Stop the token bucket pending a shutdown.