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

Class _DescriptorLock

tests/test_fork_backends.py:28–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26
27
28class _DescriptorLock(BaseFileLock):
29 acquire_error: BaseException | None = None
30 descriptor: int | None = None
31 fail_release: bool = False
32
33 def _acquire(self) -> None: # pragma: needs fork
34 self.descriptor = self._context.lock_file_fd = os.open(self.lock_file, os.O_CREAT | os.O_RDWR, 0o600)
35 if self.acquire_error is not None:
36 raise self.acquire_error
37
38 def _release(self) -> None: # pragma: needs fork
39 if self.fail_release:
40 msg = "unlock failed"
41 raise RuntimeError(msg)
42 os.close(cast("int", self._context.lock_file_fd))
43 self._context.lock_file_fd = None
44
45
46class _CoroutineDescriptorLock(BaseAsyncFileLock):

Calls

no outgoing calls