tessl install tessl/pypi-dnspython@1.16.0DNS toolkit for Python supporting almost all record types with high-level and low-level DNS operations
Agent Success
Agent success rate when using this tile
85%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.37x
Baseline
Agent success rate without this tile
62%
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.