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