| 26 | |
| 27 | |
| 28 | class _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 | |
| 46 | class _CoroutineDescriptorLock(BaseAsyncFileLock): |
no outgoing calls