Mercurial > hgrepos > Python > apps > py-cutils
comparison cutils/shasum.py @ 94:8352da172a3e
Use "fadvise()" with POSIX_FADV_SEQUENTIAL -- if available
| author | Franz Glasner <f.glasner@feldmann-mg.com> |
|---|---|
| date | Thu, 21 Apr 2022 16:01:19 +0200 |
| parents | 42419f57eda9 |
| children | fc2dd6afd594 |
comparison
equal
deleted
inserted
replaced
| 93:06b2a504b8f6 | 94:8352da172a3e |
|---|---|
| 595 use_mmap = False | 595 use_mmap = False |
| 596 if use_mmap is None: | 596 if use_mmap is None: |
| 597 use_mmap = True | 597 use_mmap = True |
| 598 if mmap is None or not use_mmap: | 598 if mmap is None or not use_mmap: |
| 599 # No mmap available or wanted -> use traditional low-level file IO | 599 # No mmap available or wanted -> use traditional low-level file IO |
| 600 fadvise = getattr(os, "posix_fadvise", None) | |
| 601 if fadvise: | |
| 602 fadvise(fd, 0, 0, os.POSIX_FADV_SEQUENTIAL) | |
| 600 while True: | 603 while True: |
| 601 try: | 604 try: |
| 602 buf = os.read(fd, READ_CHUNK_SIZE) | 605 buf = os.read(fd, READ_CHUNK_SIZE) |
| 603 except OSError as e: | 606 except OSError as e: |
| 604 if e.errno not in (errno.EAGAIN, errno.EWOULDBLOCK, | 607 if e.errno not in (errno.EAGAIN, errno.EWOULDBLOCK, |
