Skip to main content
When checking files that don’t fit in memory (10 GB+ corpora, server log streams), the standard check() API won’t work. The streaming API keeps memory bounded by processing one line at a time and yielding results as they’re ready, with backpressure control to prevent downstream bottlenecks.

Quick Start


StreamingConfig

Configuration Presets


Synchronous Streaming

Processing Files

Processing Different Input Types

Sentence-by-Sentence Processing

Process text by sentences with context preservation:

Cross-Sentence Context

When enable_cross_sentence_context=True, the checker validates using context from the previous sentence:

Async Streaming

Basic Async

Async with Timeout

Cancellation

Graceful Shutdown


Progress Tracking

Progress Callbacks

With tqdm Progress Bar

With Rich Progress Bar


StreamingStats


ChunkResult

Each iteration yields a ChunkResult:

Memory Management

Backpressure

When memory exceeds max_memory_mb, the streaming checker automatically applies backpressure:
  1. Sync mode: Triggers garbage collection and adds a small delay
  2. Async mode: Adds an async sleep to allow cleanup

Bounded Memory Usage


Error Handling

Sync Error Recovery

Async Timeout Recovery


Best Practices

  1. Reuse StreamingChecker instances because creating a new SpellChecker per file is expensive
  2. Choose chunk size by use case: 500 for throughput, 1 for real-time
  3. Use async for I/O-bound workloads such as network sources and file I/O with aiofiles
  4. Set appropriate validation level: SYLLABLE for speed, WORD for thoroughness

Integration Examples

WebSocket Streaming

FastAPI File Upload

Batch File Processing


See Also