|
14 | 14 |
|
15 | 15 | from . import hdrs, payload |
16 | 16 | from .abc import AbstractStreamWriter |
17 | | -from .compression_utils import ZLibCompressor |
| 17 | +from .compression_utils import MAX_SYNC_CHUNK_SIZE, ZLibCompressor |
18 | 18 | from .helpers import ( |
19 | 19 | ETAG_ANY, |
20 | 20 | 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", |
@@ -547,7 +546,7 @@ def __init__( |
547 | 546 | headers: LooseHeaders | None = None, |
548 | 547 | content_type: str | None = None, |
549 | 548 | charset: str | None = None, |
550 | | - zlib_executor_size: int | None = None, |
| 549 | + zlib_executor_size: int = MAX_SYNC_CHUNK_SIZE, |
551 | 550 | zlib_executor: Executor | None = None, |
552 | 551 | ) -> None: |
553 | 552 | if body is not None and text is not None: |
@@ -726,13 +725,6 @@ async def _do_start_compression(self, coding: ContentCoding) -> None: |
726 | 725 | executor=self._zlib_executor, |
727 | 726 | ) |
728 | 727 | assert self._body is not None |
729 | | - if self._zlib_executor_size is None and len(self._body) > LARGE_BODY_SIZE: |
730 | | - warnings.warn( |
731 | | - "Synchronous compression of large response bodies " |
732 | | - f"({len(self._body)} bytes) might block the async event loop. " |
733 | | - "Consider providing a custom value to zlib_executor_size/" |
734 | | - "zlib_executor response properties or disabling compression on it." |
735 | | - ) |
736 | 728 | self._compressed_body = ( |
737 | 729 | await compressor.compress(self._body) + compressor.flush() |
738 | 730 | ) |
|
0 commit comments