Skip to content

Commit e3ba57b

Browse files
gh-152074: Increase the buffer size to 256 KiB in asyncio _sendfile_fallback (#152097)
1 parent 286b512 commit e3ba57b

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

Lib/asyncio/base_events.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1296,7 +1296,10 @@ async def _sendfile_native(self, transp, file, offset, count):
12961296
async def _sendfile_fallback(self, transp, file, offset, count):
12971297
if hasattr(file, 'seek'):
12981298
file.seek(offset)
1299-
blocksize = min(count, 16384) if count else 16384
1299+
blocksize = (
1300+
min(count, constants.SENDFILE_FALLBACK_READBUFFER_SIZE)
1301+
if count else constants.SENDFILE_FALLBACK_READBUFFER_SIZE
1302+
)
13001303
buf = bytearray(blocksize)
13011304
total_sent = 0
13021305
proto = _SendfileFallbackProtocol(transp)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Increase the buffer size to 256 KiB in :meth:`asyncio.loop.sendfile` method fallback.

0 commit comments

Comments
 (0)