plaid.viewer.cache¶
plaid.viewer.cache
¶
Ephemeral artifact cache for the dataset viewer.
The cache lives under a per-process temporary directory and is removed at shutdown. Four cleanup layers cover all practical failure modes:
atexit.registerfor normal Python exit.- Signal handlers for
SIGINT/SIGTERM. - A context manager (
with CacheRoot() as cache:in the CLI). - An orphan sweep at startup that removes directories left behind by previously-crashed processes.
plaid.viewer.cache.CacheRoot
¶
Context-manager-friendly ephemeral artifact cache directory.
Creates a new tempdir named plaid-viewer-{pid}-{token} under the OS
temp root. The directory is removed at process exit (atexit), on
SIGINT / SIGTERM, and when the context manager is closed.
Source code in plaid/viewer/cache.py
plaid.viewer.cache.sweep_orphans
¶
Remove viewer tempdirs whose owning process is no longer running.
Parameters:
-
temp_root(Path | None, default:None) –Base temp directory to scan. Defaults to :func:
tempfile.gettempdir.
Returns:
-
list[Path]–List of directories that were removed.