betty.concurrent module¶
Provide utilities for concurrent programming.
- class betty.concurrent.Ledger¶
Bases:
objectLazily create locks by keeping a ledger.
The ledger lock is released once a transaction lock is acquired.
This is thread-safe, which means you can safely use this between different threads.
- final class betty.concurrent.RateLimiter¶
Bases:
objectRate-limit operations.
This class implements the Token Bucket algorithm.
This is thread-safe, which means you can safely use this between different threads.
- final class betty.concurrent.ThreadSafeLock¶
Bases:
LockAn asynchronous thread-safe lock.
This is thread-safe, which means you can safely use this between different threads.
- property lock: lock¶
The underlying, synchronous lock.
- async betty.concurrent.backoff() AsyncIterator[int]¶
Implement exponential backoff.
The returned iterator sleeps after every iteration, increasing the duration with every iteration, up to a limit.
Usage:
async for iteration in backoff(): if success: return # Or break.