Mixes ` ` and ` ` streams. The result is available in the ``output`` attribute.
| 43 | |
| 44 | |
| 45 | class StreamMixer: |
| 46 | """Mixes `<stdout>` and `<stderr>` streams. |
| 47 | |
| 48 | The result is available in the ``output`` attribute. |
| 49 | """ |
| 50 | |
| 51 | def __init__(self) -> None: |
| 52 | self.output: io.BytesIO = io.BytesIO() |
| 53 | self.stdout: io.BytesIO = BytesIOCopy(copy_to=self.output) |
| 54 | self.stderr: io.BytesIO = BytesIOCopy(copy_to=self.output) |
| 55 | |
| 56 | def __del__(self) -> None: |
| 57 | """Guarantee that file-like objects are closed in a predictable order""" |
| 58 | self.stderr.close() |
| 59 | self.stdout.close() |
| 60 | self.output.close() |
| 61 | |
| 62 | |
| 63 | class _NamedTextIOWrapper(io.TextIOWrapper): |