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)
| 348 | return AcquireReturnProxy(lock=self) |
| 349 | |
| 350 | def release(self, force: bool = False) -> None: # noqa: FBT001, FBT002 |
| 351 | """ |
| 352 | Releases the file lock. Please note, that the lock is only completely released, if the lock counter is 0. |
| 353 | Also note, that the lock file itself is not automatically deleted. |
| 354 | |
| 355 | :param force: If true, the lock counter is ignored and the lock is released in every case/ |
| 356 | |
| 357 | """ |
| 358 | if self.is_locked: |
| 359 | self._context.lock_counter -= 1 |
| 360 | |
| 361 | if self._context.lock_counter == 0 or force: |
| 362 | lock_id, lock_filename = id(self), self.lock_file |
| 363 | |
| 364 | _LOGGER.debug("Attempting to release lock %s on %s", lock_id, lock_filename) |
| 365 | self._release() |
| 366 | self._context.lock_counter = 0 |
| 367 | _LOGGER.debug("Lock %s released on %s", lock_id, lock_filename) |
| 368 | |
| 369 | def __enter__(self) -> Self: |
| 370 | """ |