MCPcopy Create free account
hub / github.com/RustPython/RustPython / _sendfile

Function _sendfile

Lib/pathlib/_os.py:88–99  ·  view source on GitHub ↗

Copy data from one regular mmap-like fd to another by using high-performance sendfile(2) syscall. This should work on Linux >= 2.6.33 only.

(source_fd, target_fd)

Source from the content-addressed store, hash-verified

86
87if hasattr(os, 'sendfile'):
88 def _sendfile(source_fd, target_fd):
89 """Copy data from one regular mmap-like fd to another by using
90 high-performance sendfile(2) syscall.
91 This should work on Linux >= 2.6.33 only.
92 """
93 blocksize = _get_copy_blocksize(source_fd)
94 offset = 0
95 while True:
96 sent = os.sendfile(target_fd, source_fd, offset, blocksize)
97 if sent == 0:
98 break # EOF
99 offset += sent
100else:
101 _sendfile = None
102

Callers 1

copyfileobjFunction · 0.85

Calls 2

_get_copy_blocksizeFunction · 0.85
sendfileMethod · 0.45

Tested by

no test coverage detected