Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Lib/asyncio/base_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ async def _sock_sendfile_fallback(self, sock, file, offset, count):
read = await self.run_in_executor(None, file.readinto, view)
if not read:
break # EOF
await self.sock_sendall(sock, view)
await self.sock_sendall(sock, view[:read])
total_sent += read
return total_sent
finally:
Expand Down Expand Up @@ -1082,7 +1082,7 @@ async def _sendfile_fallback(self, transp, file, offset, count):
if not read:
return total_sent # EOF
await proto.drain()
transp.write(view)
transp.write(view[:read])
total_sent += read
finally:
if total_sent > 0 and hasattr(file, 'seek'):
Expand Down
3 changes: 2 additions & 1 deletion Lib/test/test_asyncio/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -2117,7 +2117,8 @@ async def connect(cmd=None, **kwds):

class SendfileBase:

DATA = b"SendfileBaseData" * (1024 * 8) # 128 KiB
# 128 KiB plus small unaligned to buffer chunk
DATA = b"SendfileBaseData" * (1024 * 8 + 1)

# Reduce socket buffer size to test on relative small data sets.
BUF_SIZE = 4 * 1024 # 4 KiB
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix asyncio sendfile support when sendfile sends extra data in fallback
mode.