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)
| 86 | |
| 87 | if 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 |
| 100 | else: |
| 101 | _sendfile = None |
| 102 |
no test coverage detected