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

Method _sendfile_fallback

Lib/asyncio/base_events.py:1289–1312  ·  view source on GitHub ↗
(self, transp, file, offset, count)

Source from the content-addressed store, hash-verified

1287 "sendfile syscall is not supported")
1288
1289 async def _sendfile_fallback(self, transp, file, offset, count):
1290 if offset:
1291 file.seek(offset)
1292 blocksize = min(count, 16384) if count else 16384
1293 buf = bytearray(blocksize)
1294 total_sent = 0
1295 proto = _SendfileFallbackProtocol(transp)
1296 try:
1297 while True:
1298 if count:
1299 blocksize = min(count - total_sent, blocksize)
1300 if blocksize <= 0:
1301 return total_sent
1302 view = memoryview(buf)[:blocksize]
1303 read = await self.run_in_executor(None, file.readinto, view)
1304 if not read:
1305 return total_sent # EOF
1306 transp.write(view[:read])
1307 await proto.drain()
1308 total_sent += read
1309 finally:
1310 if total_sent > 0 and hasattr(file, 'seek'):
1311 file.seek(offset + total_sent)
1312 await proto.restore()
1313
1314 async def start_tls(self, transport, protocol, sslcontext, *,
1315 server_side=False,

Callers 1

sendfileMethod · 0.95

Calls 8

run_in_executorMethod · 0.95
minFunction · 0.85
hasattrFunction · 0.85
seekMethod · 0.45
writeMethod · 0.45
drainMethod · 0.45
restoreMethod · 0.45

Tested by

no test coverage detected