Flush the compressor synchronously. **WARNING: This method is NOT cancellation-safe when called after compress().** The flush() operation accesses shared compressor state. If compress() was cancelled, calling flush() may result in corrupted data. The connection MUST
(self, mode: int | None = None)
| 250 | return self.compress_sync(data) |
| 251 | |
| 252 | def flush(self, mode: int | None = None) -> bytes: |
| 253 | """Flush the compressor synchronously. |
| 254 | |
| 255 | **WARNING: This method is NOT cancellation-safe when called after compress().** |
| 256 | The flush() operation accesses shared compressor state. If compress() was |
| 257 | cancelled, calling flush() may result in corrupted data. The connection MUST |
| 258 | be closed after compress() cancellation. |
| 259 | |
| 260 | For cancellation-safe compression (e.g., WebSocket), the caller MUST wrap |
| 261 | compress() + flush() + send operations in a shield and lock to ensure atomicity. |
| 262 | """ |
| 263 | return self._compressor.flush( |
| 264 | mode if mode is not None else self._zlib_backend.Z_FINISH |
| 265 | ) |
| 266 | |
| 267 | |
| 268 | class ZLibDecompressor(DecompressionBaseHandler): |
no outgoing calls