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

Method release

src/filelock/asyncio.py:248–265  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

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