Source: src/cwsandbox/_types.py:262
Sync and async iterable stream reader.
StreamReader wraps an asyncio.Queue and provides both synchronous and
asynchronous iteration interfaces. This enables streaming output to be
consumed in both sync and async contexts.
Used as StreamReader[str] for text streams (exec stdout/stderr, logs)
and StreamReader[bytes] for raw byte streams (TTY output).
The stream uses None as a sentinel value to signal end-of-stream.
Exception instances in the queue are re-raised to the consumer.
Methods
close
Cancel the background producer and mark the stream as exhausted.
Safe to call multiple times. After close(), iteration will raise
StopIteration/StopAsyncIteration on the next call.
Puts a None sentinel on the queue to unblock any consumer currently
waiting inside queue.get(). Last modified on May 19, 2026