Open a temporary read-only connection. WAL mode allows concurrent readers and one writer. Each read operation gets its own connection so reads never block the event loop and never contend with the write lock.
(self)
| 224 | |
| 225 | @contextmanager |
| 226 | def _reader(self) -> Generator[sqlite3.Connection, None, None]: |
| 227 | """Open a temporary read-only connection. |
| 228 | |
| 229 | WAL mode allows concurrent readers and one writer. |
| 230 | Each read operation gets its own connection so reads never |
| 231 | block the event loop and never contend with the write lock. |
| 232 | """ |
| 233 | self._ensure_open() |
| 234 | conn = self._make_connection(read_only=True) |
| 235 | try: |
| 236 | yield conn |
| 237 | finally: |
| 238 | conn.close() |
| 239 | |
| 240 | def _cleanup_wal_on_startup(self) -> None: |
| 241 | """Remove stale WAL/SHM left by unclean shutdown. |
no test coverage detected