Why Async?
Synchronous spell checking blocks the event loop:Basic Usage
Async Check
Async Batch
Concurrent Checks
Web Framework Integration
FastAPI
Starlette
aiohttp
Configuration
Async Settings
The async API runs CPU-intensive logic in a thread pool to avoid blocking the event loop. Configuration is handled at the method level:Connection Pool for High Concurrency
Patterns
Rate Limiting
Timeout Handling
Background Processing
Streaming WebSocket
Performance
Async vs Sync Comparison
The async API significantly improves throughput under concurrent load by offloading CPU-bound work to a thread pool. Actual numbers depend on hardware, text length, validation level, and concurrency settings.These are illustrative numbers from a single test run, not formal benchmarks. Run your own load tests for production capacity planning.
Optimization Tips
- Use connection pooling for database access
- Limit concurrency to prevent resource exhaustion
- Set appropriate timeouts for production
- Cache frequently checked texts
API Reference
check_async
check_batch_async
Troubleshooting
Issue: Event loop blocked
Cause: Synchronous code in async context Solution: Ensure all I/O is async:Issue: “RuntimeError: Event loop is closed”
Cause: Checker used after loop closed Solution: Create checker within async function scope:Note: SpellChecker uses synchronous context manager (with), not async (async with). The async methods work within this context.
Issue: Database connection errors
Cause: Concurrent access without pooling Solution: Enable connection pooling:Issue: High memory usage with many connections
Cause: Too many concurrent checks Solution: Limit concurrency:Next Steps
- Batch Processing - Parallel batch processing
- Connection Pooling - Database connection management
- Performance Tuning - Optimization strategies