This situation can be managed with a pool of small (5 connections or less) to prevent spawning too many connections. This will reduce racing between them and allow write operations to succeed.
119 karma · joined November 7, 2023
This situation can be managed with a pool of small (5 connections or less) to prevent spawning too many connections. This will reduce racing between them and allow write operations to succeed.
- Opening/closing connections is fast, but not free—overhead adds up under load
- SQLite writes are globally locked
aiosqlitepool is a tiny library that adds connection pooling for any asyncio SQLite driver (like aiosqlite):
- It avoids repeated database connection setup (syscalls, memory allocation) and teardown (syscalls, deallocation) by reusing long-lived connections
- Long-lived connections keep SQLite's in-memory page cache "hot." This serves frequently requested data directly from memory, speeding up repetitive queries and reducing I/O operations
- Allows your application to process significantly more database queries per second under heavy load
Enjoy!
1. Pre-work ritual: 5 minutes of breathing exercises to clear my mind.
2. Environment setup: Focus music (playlist), all notifications off.
3. Session structure:
- 90 minute deep work blocks (using the "Deep Dive" timer)
- 15 minute breaks between sessions
4. During sessions: - Single task focus (e.g., one feature or bug)
- Handwritten notes for ideas/distractions
5. Post-session: Quick review and plan for the next block