INNER CODE UNIT · Python
build_report_with_retry
OpenOSINT/OpenOSINT · actors/domain-recon/src/main.py:149
async def build_report_with_retry(domain: str, rdap_bootstrap: dict | None) -> dict | None:
"""Build a domain report, retrying transient failures with backoff.
Returns None only if the whole pipeline (DNS + RDAP both unreachable)
fails on every attempt — a single failing domain must not fail the run.
"""
last_exc: Exception | None = None
for attempt in range(_MAX_ATTEMPTS):
try:
report = await asyncio.wait_for(
build_domain_report(domain, rdap_bootstrap), timeout=_PER_DOMAIN_TIMEOUT_SECONDS
)
# Both data sources failed — treat as a transient failure worth retrying,
# unless we've already positively confirmed the domain doesn't exist
# (retrying won't change that, and it's still a genuine finding).
if len(report["warnings"]) >= 2 and report["domainExists"] is not False and attempt < _MAX_ATTEMPTS - 1:
Actor.log.warning(f"{domain}: both DNS and RDAP failed on attempt {attempt + 1}; retrying")
await asyncio.sleep(_RETRY_BACKOFF_SECONDS * (attempt + 1))