Release the file lock. The lock is only completely released when the lock counter reaches 0. The lock file itself may be deleted automatically, the behavior is platform-specific. :param force: If true, the lock counter is ignored and the lock is released in every case.
(self, force: bool = False)
| 303 | await asyncio.sleep(poll_interval) |
| 304 | |
| 305 | async def release(self, force: bool = False) -> None: # ty: ignore[invalid-method-override] # noqa: FBT001, FBT002 |
| 306 | """ |
| 307 | Release the file lock. The lock is only completely released when the lock counter reaches 0. The lock file |
| 308 | itself may be deleted automatically, the behavior is platform-specific. |
| 309 | |
| 310 | :param force: If true, the lock counter is ignored and the lock is released in every case. |
| 311 | |
| 312 | """ |
| 313 | if self.is_locked: |
| 314 | self._context.lock_counter -= 1 |
| 315 | |
| 316 | if self._context.lock_counter == 0 or force: |
| 317 | lock_id, lock_filename = id(self), self.lock_file |
| 318 | |
| 319 | _LOGGER.debug("Attempting to release lock %s on %s", lock_id, lock_filename) |
| 320 | await self._run_internal_method(self._release) |
| 321 | self._context.lock_counter = 0 |
| 322 | _LOGGER.debug("Lock %s released on %s", lock_id, lock_filename) |
| 323 | |
| 324 | async def _run_internal_method(self, method: Callable[[], Any]) -> None: |
| 325 | if iscoroutinefunction(method): |
no test coverage detected