Stream capture¶
Context manager to capture streams stdout/stderr
Intuitive interface. Use within with block
multiprocessing.pool.Pool workers have to capture
both streams and logging output
- logging_strict.tech_niques.stream_capture.__all__: tuple[str] = ("CaptureOutput",)¶
This modules exports
- class logging_strict.tech_niques.stream_capture.CaptureOutput¶
Context manager to capture both
sys.stdoutandsys.stderrstreams- __slots__: tuple[str, str, str, str] = ("_stdout_output", "_stderr_output", "_stdout", "_stderr")¶
Reduce class memory footprint
- __enter__()¶
PEP 343 with statement Context manager. For capturing -
sys.stdout-sys.stderrcontextlibhas similiar functionality, but this is as one context manager instead of two- Returns:
class instance stores
sys.stdoutandsys.stderrinitial state- Return type:
See also
PEP 20 Rule #1 Beautiful is better than ugly
- __exit__(*args)¶
Context Manager teardown. Restores sys.stdout and sys.stderr previous state
- Parameters:
exc_type¶ (type[BaseException] | None) – Exception type
exc_value¶ (BaseException | None) – Exception value
exc_tb¶ (types.TracebackType | None) – Exception traceback if an Exception occurred