MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / _safe_unlink

Function _safe_unlink

tests/integration/test_session_export.py:70–89  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

68
69
70def _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
92def _sqlite_tables(path: Path) -> set[str]:

Calls

no outgoing calls

Tested by

no test coverage detected