Skip to main content
Synchronous spell checking blocks the event loop for ~50-200ms per call. The async API offloads CPU-bound checking to a thread pool, keeping your web server responsive under concurrent load.

Why Async?

Synchronous spell checking blocks the event loop:
Async spell checking allows concurrent handling:

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

  1. Use connection pooling for database access
  2. Limit concurrency to prevent resource exhaustion
  3. Set appropriate timeouts for production
  4. 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