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

Method release

src/filelock/asyncio.py:305–322  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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):

Callers 3

__aexit__Method · 0.95
__del__Method · 0.95
__aexit__Method · 0.45

Calls 1

_run_internal_methodMethod · 0.95

Tested by

no test coverage detected