10 Concurrency Model
Chapter Outline:
- 10.1. Thread Safety (
threading.local)- How BeaverDB provides a unique
sqlite3.Connectionfor every thread. - Why this is the key to preventing thread-related errors.
- Enabling WAL (Write-Ahead Logging) for concurrent reads.
- How BeaverDB provides a unique
- 10.2. Inter-Process Locking (The Implementation)
- How
db.lock()works under the hood. - The
beaver_lock_waiterstable as a fair (FIFO) queue. - The
expires_atcolumn as a deadlock-prevention (TTL) mechanism.
- How
- 10.3. The Asynchronous
.as_async()Pattern- How the
Async...Managerwrappers are implemented. - Using
asyncio.to_threadto run blocking I/O without blocking the event loop.
- How the