MCPcopy Create free account
hub / github.com/rthalley/dnspython / _compute_timeout

Method _compute_timeout

dns/resolver.py:1063–1085  ·  view source on GitHub ↗
(
        self,
        start: float,
        lifetime: float | None = None,
        errors: List[ErrorTuple] | None = None,
    )

Source from the content-addressed store, hash-verified

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

Callers 5

resolveMethod · 0.80
resolve_nameMethod · 0.80
resolveMethod · 0.80
resolve_nameMethod · 0.80
test_compute_timeoutMethod · 0.80

Calls 2

LifetimeTimeoutClass · 0.85
timeMethod · 0.80

Tested by 1

test_compute_timeoutMethod · 0.64