Stream Processing Examples
Handle async streams with cancelation and backpressure.
Find the complete source in examples/04_streams/.
Cancelable Stream Processing
Process async streams with automatic cancelation support.
Basic Stream Processing
from hother.cancelable import cancelable_stream, Cancelable
async def process_stream():
async with Cancelable.with_timeout(60.0) as cancel:
async for item in cancelable_stream(data_stream, cancel):
await process_item(item)
# Stream automatically stops on cancelation
Run it:
Features
- Backpressure Handling - Buffer management for fast producers
- Progress Reporting - Track stream processing progress
- Chunked Processing - Process in batches with cancelation
- Transform & Filter - Streaming transformations
Use Cases
- Data pipelines with timeout protection
- ETL operations with progress tracking
- Real-time data processing
- Event stream handling
Next Steps
- Learn Basic Patterns - Cancelation fundamentals
- Read Core Concepts - Stream processing details