diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py index e6c72e3d5b5487..bb736222b0b386 100644 --- a/Lib/asyncio/base_events.py +++ b/Lib/asyncio/base_events.py @@ -1296,7 +1296,10 @@ async def _sendfile_native(self, transp, file, offset, count): async def _sendfile_fallback(self, transp, file, offset, count): if hasattr(file, 'seek'): file.seek(offset) - blocksize = min(count, 16384) if count else 16384 + blocksize = ( + min(count, constants.SENDFILE_FALLBACK_READBUFFER_SIZE) + if count else constants.SENDFILE_FALLBACK_READBUFFER_SIZE + ) buf = bytearray(blocksize) total_sent = 0 proto = _SendfileFallbackProtocol(transp) diff --git a/Misc/NEWS.d/next/Library/2026-06-24-16-08-44.gh-issue-152074.PsbS-I.rst b/Misc/NEWS.d/next/Library/2026-06-24-16-08-44.gh-issue-152074.PsbS-I.rst new file mode 100644 index 00000000000000..05e61670582dd8 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-06-24-16-08-44.gh-issue-152074.PsbS-I.rst @@ -0,0 +1 @@ +Increase the buffer size to 256 KiB in :meth:`asyncio.loop.sendfile` method fallback.