| 34 | |
| 35 | |
| 36 | class _DescriptorLock(BaseFileLock): |
| 37 | acquire_error: BaseException | None = None |
| 38 | descriptor: int | None = None |
| 39 | fail_release: bool = False |
| 40 | |
| 41 | @override # pragma: needs fork |
| 42 | def _acquire(self) -> None: # pragma: needs fork |
| 43 | self.descriptor = self._context.lock_file_fd = os.open(self.lock_file, os.O_CREAT | os.O_RDWR, 0o600) |
| 44 | if self.acquire_error is not None: |
| 45 | raise self.acquire_error |
| 46 | |
| 47 | @override # pragma: needs fork |
| 48 | def _release(self) -> None: # pragma: needs fork |
| 49 | if self.fail_release: |
| 50 | msg = "unlock failed" |
| 51 | raise RuntimeError(msg) |
| 52 | os.close(cast("int", self._context.lock_file_fd)) |
| 53 | self._context.lock_file_fd = None |
| 54 | |
| 55 | |
| 56 | def test_direct_descriptor_backend_keeps_new_hold_on_interrupted_release(tmp_path: Path, mocker: MockerFixture) -> None: |
no outgoing calls