|
16 | 16 |
|
17 | 17 | from . import hdrs, payload |
18 | 18 | from .abc import AbstractStreamWriter |
19 | | -from .compression_utils import ZLibCompressor |
| 19 | +from .compression_utils import MAX_SYNC_CHUNK_SIZE, ZLibCompressor |
20 | 20 | from .helpers import ( |
21 | 21 | ETAG_ANY, |
22 | 22 | QUOTED_ETAG_RE, |
|
35 | 35 | from .typedefs import JSONBytesEncoder, JSONEncoder, LooseHeaders |
36 | 36 |
|
37 | 37 | REASON_PHRASES = {http_status.value: http_status.phrase for http_status in HTTPStatus} |
38 | | -LARGE_BODY_SIZE = 1024**2 |
39 | 38 |
|
40 | 39 | __all__ = ( |
41 | 40 | "ContentCoding", |
@@ -665,7 +664,7 @@ def __init__( |
665 | 664 | headers: LooseHeaders | None = None, |
666 | 665 | content_type: str | None = None, |
667 | 666 | charset: str | None = None, |
668 | | - zlib_executor_size: int | None = None, |
| 667 | + zlib_executor_size: int = MAX_SYNC_CHUNK_SIZE, |
669 | 668 | zlib_executor: Executor | None = None, |
670 | 669 | ) -> None: |
671 | 670 | if body is not None and text is not None: |
@@ -846,13 +845,6 @@ async def _do_start_compression(self, coding: ContentCoding) -> None: |
846 | 845 | executor=self._zlib_executor, |
847 | 846 | ) |
848 | 847 | assert self._body is not None |
849 | | - if self._zlib_executor_size is None and len(self._body) > LARGE_BODY_SIZE: |
850 | | - warnings.warn( |
851 | | - "Synchronous compression of large response bodies " |
852 | | - f"({len(self._body)} bytes) might block the async event loop. " |
853 | | - "Consider providing a custom value to zlib_executor_size/" |
854 | | - "zlib_executor response properties or disabling compression on it." |
855 | | - ) |
856 | 848 | self._compressed_body = ( |
857 | 849 | await compressor.compress(self._body) + compressor.flush() |
858 | 850 | ) |
|
0 commit comments