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

Function read_lock

ci/util/file_lock_rw.py:249–272  ·  view source on GitHub ↗

Create a read lock for a file. Allows multiple concurrent readers. Blocks only if a writer holds the lock. Args: file_path: Path to the file to lock timeout: Optional timeout in seconds operation: Description of the operation Returns: FileLock cont

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

Source from the content-addressed store, hash-verified

247
248
249def read_lock(
250 file_path: Path, timeout: float | None = None, operation: str = "read"
251) -> FileLock:
252 """
253 Create a read lock for a file.
254
255 Allows multiple concurrent readers. Blocks only if a writer holds the lock.
256
257 Args:
258 file_path: Path to the file to lock
259 timeout: Optional timeout in seconds
260 operation: Description of the operation
261
262 Returns:
263 FileLock context manager
264
265 Example:
266 with read_lock(Path("data.json"), timeout=5.0) as lock:
267 # Read from file safely
268 with open("data.json", "r") as f:
269 data = json.load(f)
270 """
271 lock_file = file_path.parent / f".{file_path.name}.lock"
272 return FileLock(lock_file, timeout=timeout, operation=operation, mode="read")
273
274
275def custom_lock(

Callers 2

test_read_lock_helperMethod · 0.90

Calls 1

FileLockClass · 0.85

Tested by 2

test_read_lock_helperMethod · 0.72