MCPcopy Index your code
hub / github.com/RustPython/RustPython / _sock_sendfile_fallback

Method _sock_sendfile_fallback

Lib/asyncio/base_events.py:965–989  ·  view source on GitHub ↗
(self, sock, file, offset, count)

Source from the content-addressed store, hash-verified

963 f"and file {file!r} combination")
964
965 async def _sock_sendfile_fallback(self, sock, file, offset, count):
966 if offset:
967 file.seek(offset)
968 blocksize = (
969 min(count, constants.SENDFILE_FALLBACK_READBUFFER_SIZE)
970 if count else constants.SENDFILE_FALLBACK_READBUFFER_SIZE
971 )
972 buf = bytearray(blocksize)
973 total_sent = 0
974 try:
975 while True:
976 if count:
977 blocksize = min(count - total_sent, blocksize)
978 if blocksize <= 0:
979 break
980 view = memoryview(buf)[:blocksize]
981 read = await self.run_in_executor(None, file.readinto, view)
982 if not read:
983 break # EOF
984 await self.sock_sendall(sock, view[:read])
985 total_sent += read
986 return total_sent
987 finally:
988 if total_sent > 0 and hasattr(file, 'seek'):
989 file.seek(offset + total_sent)
990
991 def _check_sendfile_params(self, sock, file, offset, count):
992 if 'b' not in getattr(file, 'mode', 'b'):

Callers 1

sock_sendfileMethod · 0.95

Calls 5

run_in_executorMethod · 0.95
minFunction · 0.85
hasattrFunction · 0.85
seekMethod · 0.45
sock_sendallMethod · 0.45

Tested by

no test coverage detected