betty.concurrent module

Provide utilities for concurrent programming.

final class betty.concurrent.AsynchronizedLock[source]

Bases: Lock

Make a sychronous (blocking) lock asynchronous (non-blocking).

__init__(lock: allocate_lock)[source]
async acquire(*, wait: bool = True) bool[source]

Acquire the lock.

async release() None[source]

Release the lock.

classmethod threading() Self[source]

Create a new thread-safe, asynchronous lock.

class betty.concurrent.Lock[source]

Bases: ABC

Provide an asynchronous lock.

abstract async acquire(*, wait: bool = True) bool[source]

Acquire the lock.

abstract async release() None[source]

Release the lock.

final class betty.concurrent.RateLimiter[source]

Bases: object

Rate-limit operations.

This class implements the Token Bucket algorithm.

This class is thread-safe.

__init__(maximum: int)[source]
async wait() None[source]

Wait until an operation may be performed (again).

async betty.concurrent.asynchronize_acquire(lock: allocate_lock, *, wait: bool = True) bool[source]

Acquire a synchronous lock asynchronously.