build_lock#
- scikitplot.cython.build_lock(lock_dir, *, timeout_s=60.0, poll_s=0.05)[source]#
Acquire an exclusive build lock via atomic directory creation.
- Parameters:
- lock_dirpathlib.Path
Lock directory path to create atomically.
- timeout_sfloat, default=60.0
Maximum seconds to wait for the lock. A value of
0makes a single acquisition attempt and raisesTimeoutErrorimmediately if the lock is already held.- poll_sfloat, default=0.05
Sleep interval in seconds between acquisition retries.
- Returns:
- Iterator[None]
Context manager that yields once the lock is held.
- Raises:
- TimeoutError
If the lock cannot be acquired within
timeout_sseconds.- ValueError
If
timeout_s < 0orpoll_s <= 0.
- Parameters:
- Return type:
Iterator[None]
Notes
Stale lock recovery: if a lock directory exists but its
mtimeis older thantimeout_sseconds, it is treated as stale (left by a killed process) and removed before the next acquisition attempt. This prevents permanent deadlock after hard crashes.Clean release: the lock directory is always removed in the
finallyblock, so normal exceptions inside thewithbody release the lock correctly.