Rename a directory, retrying briefly: on Windows a virus scanner or indexer can hold a just-written file open and fail the rename with PermissionError.
(src: Path, dst: Path)
| 18 | |
| 19 | |
| 20 | def _rename(src: Path, dst: Path) -> None: |
| 21 | """Rename a directory, retrying briefly: on Windows a virus scanner or indexer |
| 22 | can hold a just-written file open and fail the rename with PermissionError.""" |
| 23 | for attempt in range(20): |
| 24 | try: |
| 25 | src.rename(dst) |
| 26 | return |
| 27 | except PermissionError: |
| 28 | if attempt == 19: |
| 29 | raise |
| 30 | time.sleep(0.25) |
| 31 | |
| 32 | |
| 33 | def _run(args: list[str], cwd: Path, env: dict[str, str] | None = None) -> subprocess.CompletedProcess: |
no outgoing calls
no test coverage detected