Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
View this page
Toggle table of contents sidebar

# betty.concurrent module

Provide utilities for concurrent programming.

final class betty.concurrent.AsynchronizedLock

  Bases: `_Lock`

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

  __init__(lock: allocate_lock)
  async acquire(*, wait: bool = True) → bool

    Acquire the lock.

  release() → None

    Release the lock.

  classmethod threading() → Self

    Create a new thread-safe, asynchronous lock.

final class betty.concurrent.MultiLock

  Bases: `_Lock`

  Provide a lock that only acquires if all of the given locks can be acquired.

  __init__(*locks: _Lock)
  async acquire(*, wait: bool = True) → bool

    Acquire the lock.

  release() → None

    Release the lock.

final class betty.concurrent.RateLimiter

  Bases: `object`

  Rate-limit operations.

  This class implements the Token Bucket algorithm.

  This class is thread-safe.

  __init__(maximum: int)
  async wait() → None

    Wait until an operation may be performed (again).

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

  Acquire a synchronous lock asynchronously.