class documentation
Wrapper that automatically flushes a TextIO stream based on configuration.
This wrapper can be configured to flush after each write operation, which is useful for real-time output monitoring in CI/CD systems.
| Class Method | env |
Create wrapper respecting the GIT_FLUSH environment variable. |
| Method | __enter__ |
Support context manager protocol. |
| Method | __exit__ |
Support context manager protocol. |
| Method | __getattr__ |
Delegate all other attributes to the underlying stream. |
| Method | __init__ |
Initialize the wrapper. |
| Method | flush |
Flush the underlying stream. |
| Method | write |
Write data to the stream and optionally flush. |
| Method | writelines |
Write multiple lines to the stream and optionally flush. |
| Instance Variable | _stream |
Undocumented |
def env(cls, stream:
TextIO, env: Mapping[ str, str] | None = None) -> AutoFlushTextIOWrapper | TextIO:
¶
Create wrapper respecting the GIT_FLUSH environment variable.
Respects the GIT_FLUSH environment variable: - GIT_FLUSH=1: Always flush after each write - GIT_FLUSH=0: Never auto-flush (use buffered I/O) - Not set: Auto-detect based on whether output is redirected
| Parameters | |
stream:TextIO | The stream to wrap |
env:Mapping[ | Environment variables dict (defaults to os.environ) |
| Returns | |
AutoFlushTextIOWrapper | TextIO | AutoFlushTextIOWrapper instance configured based on GIT_FLUSH |
def __exit__(self, exc_type:
type[ BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None):
¶
Support context manager protocol.