Delete a session DB, tolerating a briefly-held handle. On Windows an open SQLite file cannot be removed (WinError 32), and the handle can linger past sessions.close (OS release lag, or a reader connection). This unlink is housekeeping, not an assertion -- the schema and row-cou
(path: Path)
| 68 | |
| 69 | |
| 70 | def _safe_unlink(path: Path) -> None: |
| 71 | """ |
| 72 | Delete a session DB, tolerating a briefly-held handle. |
| 73 | |
| 74 | On Windows an open SQLite file cannot be removed (WinError 32), and the |
| 75 | handle can linger past sessions.close (OS release lag, or a reader |
| 76 | connection). This unlink is housekeeping, not an assertion -- the schema |
| 77 | and row-count checks have already run -- so retry a few times and then give |
| 78 | up quietly rather than failing the test on a cleanup artifact. |
| 79 | """ |
| 80 | for attempt in range(10): |
| 81 | try: |
| 82 | path.unlink() |
| 83 | return |
| 84 | except FileNotFoundError: |
| 85 | return |
| 86 | except PermissionError: |
| 87 | if attempt == 9: |
| 88 | return |
| 89 | time.sleep(0.3) |
| 90 | |
| 91 | |
| 92 | def _sqlite_tables(path: Path) -> set[str]: |
no outgoing calls
no test coverage detected