Create a lock with a custom lock file path. Useful when you want to lock a resource that isn't a file, or when you need a specific lock file location. Args: lock_file_path: Explicit path to the lock file timeout: Optional timeout in seconds operation: Descr
(
lock_file_path: Path, timeout: float | None = None, operation: str = "custom"
)
| 273 | |
| 274 | |
| 275 | def custom_lock( |
| 276 | lock_file_path: Path, timeout: float | None = None, operation: str = "custom" |
| 277 | ) -> FileLock: |
| 278 | """ |
| 279 | Create a lock with a custom lock file path. |
| 280 | |
| 281 | Useful when you want to lock a resource that isn't a file, |
| 282 | or when you need a specific lock file location. |
| 283 | |
| 284 | Args: |
| 285 | lock_file_path: Explicit path to the lock file |
| 286 | timeout: Optional timeout in seconds |
| 287 | operation: Description of the operation |
| 288 | |
| 289 | Returns: |
| 290 | FileLock context manager |
| 291 | |
| 292 | Example: |
| 293 | lock_path = cache_dir / "download.lock" |
| 294 | with custom_lock(lock_path, timeout=5.0, operation="download") as lock: |
| 295 | # Perform locked operation |
| 296 | download_file(url, dest) |
| 297 | """ |
| 298 | return FileLock(lock_file_path, timeout=timeout, operation=operation) |
| 299 | |
| 300 | |
| 301 | def download_lock(artifact_dir: Path, timeout: float = 5.0) -> FileLock: |
no test coverage detected