betty.concurrent module¶
Provide utilities for concurrent programming.
- final class betty.concurrent.AsynchronizedLock[source]¶
Bases:
Lock
Make a synchronous (blocking) lock asynchronous (non-blocking).
- property lock: lock¶
The underlying, synchronous lock.
- class betty.concurrent.Ledger[source]¶
Bases:
object
Lazily create locks by keeping a ledger.
The ledger lock is released once a transaction lock is acquired.
This can be pickled.
This is thread-safe, which means you can safely use this between different threads.
This is process-safe, which means you can safely use this between different processes.
- __init__(ledger_lock: Lock, *, manager: SyncManager | None = None)[source]¶
- final class betty.concurrent.RateLimiter[source]¶
Bases:
object
Rate-limit operations.
This class implements the Token Bucket algorithm.
This can be pickled.
This is thread-safe, which means you can safely use this between different threads.
This is process-safe, which means you can safely use this between different processes.
- async betty.concurrent.asynchronize_acquire(lock: lock, *, wait: bool = True) bool [source]¶
Acquire a synchronous lock asynchronously.
- betty.concurrent.ensure_manager(manager: SyncManager | None, *, stacklevel: int = 1) SyncManager [source]¶
Ensure that a value is a multiprocessing manager.