Async 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``
(self, timeout: float | None = None, *, blocking: bool | None = None)
| 173 | |
| 174 | @asynccontextmanager |
| 175 | async def write_lock(self, timeout: float | None = None, *, blocking: bool | None = None) -> AsyncGenerator[None]: |
| 176 | """ |
| 177 | Async context manager that acquires and releases an exclusive write lock. |
| 178 | |
| 179 | Falls back to instance defaults for *timeout* and *blocking* when ``None``. |
| 180 | |
| 181 | :param timeout: maximum wait time in seconds, or ``None`` to use the instance default |
| 182 | :param blocking: if ``False``, raise :class:`~filelock.Timeout` immediately; ``None`` uses the instance default |
| 183 | |
| 184 | """ |
| 185 | if timeout is None: |
| 186 | timeout = self._lock.timeout |
| 187 | if blocking is None: |
| 188 | blocking = self._lock.blocking |
| 189 | await self.acquire_write(timeout, blocking=blocking) |
| 190 | try: |
| 191 | yield |
| 192 | finally: |
| 193 | await self.release() |
| 194 | |
| 195 | async def close(self) -> None: |
| 196 | """ |