Raised when strict soft-lock state cannot be interpreted without risking overlap.
| 33 | |
| 34 | |
| 35 | class SoftFileLockProtocolError(OSError): |
| 36 | """Raised when strict soft-lock state cannot be interpreted without risking overlap.""" |
| 37 | |
| 38 | def __init__(self, lock_file: str, claim_name: str | None, reason: str) -> None: |
| 39 | self._lock_file = lock_file |
| 40 | self._claim_name = claim_name |
| 41 | self._reason = reason |
| 42 | super().__init__(self.__str__()) |
| 43 | |
| 44 | def __reduce__( |
| 45 | self, |
| 46 | ) -> tuple[type[SoftFileLockProtocolError], tuple[str, str | None, str]]: # pragma: needs hard-link |
| 47 | return self.__class__, (self._lock_file, self._claim_name, self._reason) |
| 48 | |
| 49 | def __str__(self) -> str: |
| 50 | location = self._lock_file if self._claim_name is None else f"{self._lock_file}: claim {self._claim_name!r}" |
| 51 | return f"Invalid strict soft-lock state at {location}: {self._reason}" |
| 52 | |
| 53 | @property |
| 54 | def lock_file(self) -> str: # pragma: needs hard-link |
| 55 | """The requested lock path.""" |
| 56 | return self._lock_file |
| 57 | |
| 58 | @property |
| 59 | def claim_name(self) -> str | None: # pragma: needs hard-link |
| 60 | """The claim that caused the error, if scanning identified one.""" |
| 61 | return self._claim_name |
| 62 | |
| 63 | @property |
| 64 | def reason(self) -> str: # pragma: needs hard-link |
| 65 | """The protocol validation failure.""" |
| 66 | return self._reason |
| 67 | |
| 68 | |
| 69 | __all__ = [ |
no outgoing calls