Releases the file lock. Please note, that the lock is only completely released, if the lock counter is 0. Also note, that the lock file itself is not automatically deleted. :param force: If true, the lock counter is ignored and the lock is released in every case/
(self, force: bool = False)
| 246 | return AsyncAcquireReturnProxy(lock=self) |
| 247 | |
| 248 | async def release(self, force: bool = False) -> None: # type: ignore[override] # noqa: FBT001, FBT002 |
| 249 | """ |
| 250 | Releases the file lock. Please note, that the lock is only completely released, if the lock counter is 0. |
| 251 | Also note, that the lock file itself is not automatically deleted. |
| 252 | |
| 253 | :param force: If true, the lock counter is ignored and the lock is released in every case/ |
| 254 | |
| 255 | """ |
| 256 | if self.is_locked: |
| 257 | self._context.lock_counter -= 1 |
| 258 | |
| 259 | if self._context.lock_counter == 0 or force: |
| 260 | lock_id, lock_filename = id(self), self.lock_file |
| 261 | |
| 262 | _LOGGER.debug("Attempting to release lock %s on %s", lock_id, lock_filename) |
| 263 | await self._run_internal_method(self._release) |
| 264 | self._context.lock_counter = 0 |
| 265 | _LOGGER.debug("Lock %s released on %s", lock_id, lock_filename) |
| 266 | |
| 267 | async def _run_internal_method(self, method: Callable[[], Any]) -> None: |
| 268 | if asyncio.iscoroutinefunction(method): |
no test coverage detected