DNS toolkit for Python supporting almost all record types with high-level and low-level DNS operations
85
Build a helper that performs DNS lookups safely across multiple threads by sharing a package-provided cache and returning immutable results. The helper should make it easy to warm the cache up front, perform single and batch lookups, and keep per-call timeout overrides isolated to the calling thread.
lookup calls for the same hostname reuse a single cache entry so both return identical address tuples, and later calls serve from the cache instead of triggering another query. @testlookup and lookup_many are immutable snapshots; mutating a returned collection does not affect subsequent calls or cached data. @testlookup_many enforces that limit for each query without altering the default timeout used for later calls. @test@generates
from typing import Iterable, Mapping, Tuple, Optional
class ThreadSafeDnsHelper:
def __init__(self, nameservers: Iterable[str], default_timeout: float = 2.0) -> None: ...
def warm_cache(self, hostnames: Iterable[str], record_type: str = "A", timeout: Optional[float] = None) -> None: ...
def lookup(self, hostname: str, record_type: str = "A", timeout: Optional[float] = None) -> Tuple[str, ...]: ...
def lookup_many(self, hostnames: Iterable[str], record_type: str = "A", timeout: Optional[float] = None) -> Mapping[str, Tuple[str, ...]]: ...Provides DNS resolution, immutable-friendly record objects, and resolver caches suitable for multi-threaded use.
Install with Tessl CLI
npx tessl i tessl/pypi-dnspythondocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10