MCPcopy Create free account
hub / github.com/FastLED/FastLED / download_lock

Function download_lock

ci/util/file_lock_rw.py:301–326  ·  view source on GitHub ↗

Create a lock for download operations with stale detection. This is the recommended lock for toolchain/package downloads. Uses 5-second timeout by default with automatic stale lock recovery. Args: artifact_dir: Cache artifact directory being downloaded to timeout:

(artifact_dir: Path, timeout: float = 5.0)

Source from the content-addressed store, hash-verified

299
300
301def download_lock(artifact_dir: Path, timeout: float = 5.0) -> FileLock:
302 """
303 Create a lock for download operations with stale detection.
304
305 This is the recommended lock for toolchain/package downloads.
306 Uses 5-second timeout by default with automatic stale lock recovery.
307
308 Args:
309 artifact_dir: Cache artifact directory being downloaded to
310 timeout: Timeout in seconds (default: 5.0)
311
312 Returns:
313 FileLock context manager
314
315 Example:
316 cache_dir = Path("~/.platformio/global_cache")
317 artifact_dir = cache_dir / "toolchain-xyz"
318
319 with download_lock(artifact_dir) as lock:
320 # Download inside lock
321 download_file(url, artifact_dir / "toolchain.zip")
322 # Write breadcrumb inside lock
323 write_breadcrumb(artifact_dir / "info.json", data)
324 """
325 lock_file = artifact_dir / ".download.lock"
326 return FileLock(lock_file, timeout=timeout, operation="download")

Callers

nothing calls this directly

Calls 1

FileLockClass · 0.85

Tested by

no test coverage detected