exlab_wizard.sync.file_stability#
Pre-rclone file-stability guard: confirm files have stopped growing.
Polls st_size on a fixed interval and reports whether a file’s size has
been identical across N consecutive observations. Used as a pre-flight check
before rclone sync invocations so only complete files transfer.
The module is intentionally stdlib-only and free of project imports so it can be reused unchanged by external job scripts / a CLI as well as by the in-process sync worker.
Functions
|
Return True once |
|
Poll |
- exlab_wizard.sync.file_stability.is_stable(path, interval, checks, timeout)[source]#
Return True once
path’s size is constant acrosscheckspolls.- Parameters:
- Return type:
- Returns:
True if the size was identical across
checksconsecutive polls (an all-zero-size file counts as stable). False if the file disappears at any poll or the timeout elapses first.- Raises:
ValueError – If
interval <= 0orchecks < 2.
Notes
On NFS mounts set
interval >= actimeo(typically >= 30 s) so the attribute cache does not mask a still-growing file. On Windows an exclusively-locked file may reportsize == 0viastat(); account for that at the call site. No busy-wait:time.sleepis used between polls. Thread-safe: no shared mutable state.
- exlab_wizard.sync.file_stability.wait_until_stable(paths, interval, checks, timeout, max_workers=8)[source]#
Poll
pathsconcurrently; return(stable, unstable).- Parameters:
interval (
float) – Seconds between polls (forwarded tois_stable()).checks (
int) – Consecutive equal observations required.timeout (
float) – Per-file wall-clock budget in seconds.max_workers (
int) – Thread cap (one thread per file, bounded) to avoid NFS overload. Defaults to 8.
- Returns:
files that reached stability, and files that did not (missing, still growing, or timed out).
- Return type:
- Raises:
ValueError – If
interval <= 0orchecks < 2(validated per file byis_stable()).