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

Function write_lock

ci/util/file_lock_rw.py:225–246  ·  view source on GitHub ↗

Create a write lock for a file. Args: file_path: Path to the file to lock timeout: Optional timeout in seconds operation: Description of the operation Returns: FileLock context manager Example: with write_lock(Path("data.json"), timeout=5.0

(
    file_path: Path, timeout: float | None = None, operation: str = "write"
)

Source from the content-addressed store, hash-verified

223
224
225def write_lock(
226 file_path: Path, timeout: float | None = None, operation: str = "write"
227) -> FileLock:
228 """
229 Create a write lock for a file.
230
231 Args:
232 file_path: Path to the file to lock
233 timeout: Optional timeout in seconds
234 operation: Description of the operation
235
236 Returns:
237 FileLock context manager
238
239 Example:
240 with write_lock(Path("data.json"), timeout=5.0) as lock:
241 # Write to file safely
242 with open("data.json", "w") as f:
243 json.dump(data, f)
244 """
245 lock_file = file_path.parent / f".{file_path.name}.lock"
246 return FileLock(lock_file, timeout=timeout, operation=operation, mode="write")
247
248
249def read_lock(

Callers 3

write_breadcrumbFunction · 0.90
_saveMethod · 0.90

Calls 1

FileLockClass · 0.85

Tested by 1