| 1061 | raise NotImplementedError |
| 1062 | |
| 1063 | def _compute_timeout( |
| 1064 | self, |
| 1065 | start: float, |
| 1066 | lifetime: float | None = None, |
| 1067 | errors: List[ErrorTuple] | None = None, |
| 1068 | ) -> float: |
| 1069 | lifetime = self.lifetime if lifetime is None else lifetime |
| 1070 | now = time.time() |
| 1071 | duration = now - start |
| 1072 | if errors is None: |
| 1073 | errors = [] |
| 1074 | if duration < 0: |
| 1075 | if duration < -1: |
| 1076 | # Time going backwards is bad. Just give up. |
| 1077 | raise LifetimeTimeout(timeout=duration, errors=errors) |
| 1078 | else: |
| 1079 | # Time went backwards, but only a little. This can |
| 1080 | # happen, e.g. under vmware with older linux kernels. |
| 1081 | # Pretend it didn't happen. |
| 1082 | duration = 0 |
| 1083 | if duration >= lifetime: |
| 1084 | raise LifetimeTimeout(timeout=duration, errors=errors) |
| 1085 | return min(lifetime - duration, self.timeout) |
| 1086 | |
| 1087 | def _get_qnames_to_try( |
| 1088 | self, qname: dns.name.Name, search: bool | None |