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

Method release

src/filelock/_api.py:350–367  ·  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

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 """

Callers 15

__exit__Method · 0.95
__del__Method · 0.95
__exit__Method · 0.45
test_timeoutFunction · 0.45
test_non_blockingFunction · 0.45
test_default_timeoutFunction · 0.45
test_delFunction · 0.45
test_lock_modeFunction · 0.45
test_lock_mode_softFunction · 0.45
test_umaskFunction · 0.45
test_umask_softFunction · 0.45

Calls 1

_releaseMethod · 0.95

Tested by 12

test_timeoutFunction · 0.36
test_non_blockingFunction · 0.36
test_default_timeoutFunction · 0.36
test_delFunction · 0.36
test_lock_modeFunction · 0.36
test_lock_mode_softFunction · 0.36
test_umaskFunction · 0.36
test_umask_softFunction · 0.36
test_non_blockingFunction · 0.36
test_coroutine_functionFunction · 0.36