Skip to main content
When multiple threads access the spell checker concurrently (e.g., in a web server), the connection pool manages SQLite connections safely by creating them on demand, validating before use, and recycling aged connections.

Overview

Features

Configuration

ConnectionPoolConfig

Configuration Options

Basic Usage

Context Manager

Pool Lifecycle

As Context Manager

Thread Safety

Multi-threaded Usage

Thread Isolation

By default, check_same_thread=False allows connections to be used across threads:

Connection Health

Automatic Health Checks

The pool validates connections before checkout and on return:

Connection Recreation

Old or unhealthy connections are automatically recreated:

Error Handling

Timeout Handling

Database Errors

Statistics and Monitoring

Get Pool Stats

Stats Fields

Monitoring Example

Integration with Providers

SQLiteProvider Usage

SpellChecker Integration

Performance Tuning

Pool Sizing

Timeout Tuning

Connection Age

PooledConnection

Internal connection wrapper with metadata:

Best Practices

Always Use Context Manager

Close Pool on Shutdown

Monitor Pool Usage

Handle Exhaustion Gracefully

See Also