Patch ``io.BytesIO`` to let the written stream be copied to another. .. versionadded:: 8.2
| 115 | |
| 116 | |
| 117 | class BytesIOCopy(io.BytesIO): |
| 118 | """Patch ``io.BytesIO`` to let the written stream be copied to another. |
| 119 | |
| 120 | .. versionadded:: 8.2 |
| 121 | """ |
| 122 | |
| 123 | copy_to: io.BytesIO |
| 124 | |
| 125 | def __init__(self, copy_to: io.BytesIO) -> None: |
| 126 | super().__init__() |
| 127 | self.copy_to = copy_to |
| 128 | |
| 129 | def flush(self) -> None: |
| 130 | super().flush() |
| 131 | self.copy_to.flush() |
| 132 | |
| 133 | def write(self, b: ReadableBuffer) -> int: |
| 134 | self.copy_to.write(b) |
| 135 | return super().write(b) |
| 136 | |
| 137 | |
| 138 | class StreamMixer: |
no outgoing calls