MCPcopy Create free account
hub / github.com/tox-dev/filelock / write_lock

Method write_lock

src/filelock/_read_write.py:390–408  ·  view source on GitHub ↗

Context manager that acquires and releases an exclusive write lock. Falls back to instance defaults for *timeout* and *blocking* when ``None``. :param timeout: maximum wait time in seconds, or ``None`` to use the instance default :param blocking: if ``False``, rais

(self, timeout: float | None = None, *, blocking: bool | None = None)

Source from the content-addressed store, hash-verified

388
389 @contextmanager
390 def write_lock(self, timeout: float | None = None, *, blocking: bool | None = None) -> Generator[None]:
391 """
392 Context manager that acquires and releases an exclusive write lock.
393
394 Falls back to instance defaults for *timeout* and *blocking* when ``None``.
395
396 :param timeout: maximum wait time in seconds, or ``None`` to use the instance default
397 :param blocking: if ``False``, raise :class:`~filelock.Timeout` immediately; ``None`` uses the instance default
398
399 """
400 if timeout is None:
401 timeout = self.timeout
402 if blocking is None:
403 blocking = self.blocking
404 self.acquire_write(timeout, blocking=blocking)
405 try:
406 yield
407 finally:
408 self.release()
409
410 def release(self, *, force: bool = False) -> None:
411 """

Calls 2

acquire_writeMethod · 0.95
releaseMethod · 0.95