Raised when strict soft-lock state cannot be interpreted without risking overlap. :param lock_file: the path of the lock :param claim_name: the name of the claim the state belongs to, or ``None`` when it concerns the lock as a whole :param reason: why the state cannot be interprete
| 82 | |
| 83 | |
| 84 | class SoftFileLockProtocolError(OSError): |
| 85 | """ |
| 86 | Raised when strict soft-lock state cannot be interpreted without risking overlap. |
| 87 | |
| 88 | :param lock_file: the path of the lock |
| 89 | :param claim_name: the name of the claim the state belongs to, or ``None`` when it concerns the lock as a whole |
| 90 | :param reason: why the state cannot be interpreted |
| 91 | """ |
| 92 | |
| 93 | def __init__(self, lock_file: str, claim_name: str | None, reason: str) -> None: |
| 94 | self._lock_file = lock_file |
| 95 | self._claim_name = claim_name |
| 96 | self._reason = reason |
| 97 | super().__init__(self.__str__()) |
| 98 | |
| 99 | @override |
| 100 | def __str__(self) -> str: |
| 101 | location = self._lock_file if self._claim_name is None else f"{self._lock_file}: claim {self._claim_name!r}" |
| 102 | return f"Invalid strict soft-lock state at {location}: {self._reason}" |
| 103 | |
| 104 | @override |
| 105 | def __reduce__( |
| 106 | self, |
| 107 | ) -> tuple[ |
| 108 | type[SoftFileLockProtocolError], |
| 109 | tuple[str, str | None, str], |
| 110 | dict[str, object], # simplint: ignore[imprecise-annotation] # pickle state is heterogeneous |
| 111 | ]: # pragma: needs hard-link |
| 112 | return self.__class__, (self._lock_file, self._claim_name, self._reason), self.__dict__ |
| 113 | |
| 114 | @property |
| 115 | def lock_file(self) -> str: # pragma: needs hard-link |
| 116 | """The requested lock path.""" |
| 117 | return self._lock_file |
| 118 | |
| 119 | @property |
| 120 | def claim_name(self) -> str | None: # pragma: needs hard-link |
| 121 | """The claim that caused the error, if scanning identified one.""" |
| 122 | return self._claim_name |
| 123 | |
| 124 | @property |
| 125 | def reason(self) -> str: # pragma: needs hard-link |
| 126 | """The protocol validation failure.""" |
| 127 | return self._reason |
| 128 | |
| 129 | |
| 130 | _MarkerValue = TypeVar("_MarkerValue") |
no outgoing calls