Refactor collect_path_diversity to run probes concurrently using asyncio.gather.

Co-authored-by: Horizontal42 <75383519+Horizontal42@users.noreply.github.com>
This commit is contained in:
google-labs-jules[bot] 2026-08-19 11:32:55 +00:00 • committed by Andrew Pimenov
parent 67f677a536
commit 9ebdc19a94

View file

@ -1,5 +1,6 @@
from __future__ import annotations
import asyncio
import re
import httpx
@ -158,8 +159,9 @@ async def collect_path_diversity(
timeout: float,
source_ip: str | None = None,
) -> PathDiversity:
hops = [
await probe_edge(client, host, timeout=timeout, source_ip=source_ip)
coros = [
probe_edge(client, host, timeout=timeout, source_ip=source_ip)
for _label, host in targets[:max_targets]
]
return build_path_diversity(client_country, hops)
hops = await asyncio.gather(*coros)
return build_path_diversity(client_country, list(hops))