CRITICAL: Async generators can leak resources if not properly cleaned up. Python 3.10+ provides aclosing() from contextlib to guarantee cleanup.
| External API streaming (LLM, HTTP) | ✅ Always | | Database streaming results | ✅ Always | | File streaming | ✅ Always | | Simple in-memory generators | ⚠️ Optional (no cleanup needed) | | Generator with try/finally cleanup | ✅ Always |
| Server-to-Client Streaming | SSE | Simple protocol, auto-reconnect, HTTP/2 compatible | | Bidirectional Communication | WebSockets | Full-duplex, low latency, binary support | | LLM Token Streaming | ReadableStream + SSE | Backpressure control, standard format | | Reconnection Strategy | Exponential Backoff | Prevents thundering herd, graceful recovery |
Streaming di dati in tempo reale con SSE, WebSocket e ReadableStream. Da utilizzare durante l'implementazione di risposte in streaming, aggiornamenti dei dati in tempo reale, eventi inviati dal server, configurazione WebSocket, notifiche in tempo reale, aggiornamenti push o backend del server di chat. Fonte: yonatangross/orchestkit.