mirror of
https://github.com/Horizontal42/netsleuth.git
synced 2026-11-11 01:02:10 +03:00
perf: flatten DoH tasks for concurrent gathering (#15)
Modified `collect_dns_advanced` to gather DoH probes simultaneously by building a single list of tasks, replacing the sequential gathering loop. Added a similar concurrent optimization to `system_probes` fetching. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
This commit is contained in:
parent
3ab957fd0e
commit
67f677a536
1 changed files with 7 additions and 8 deletions
|
|
@ -141,14 +141,13 @@ async def collect_dns_advanced(
|
||||||
bogus_probe_name: str,
|
bogus_probe_name: str,
|
||||||
timeout: float,
|
timeout: float,
|
||||||
) -> DnsAdvanced:
|
) -> DnsAdvanced:
|
||||||
system_probes = [await resolve_system(name, timeout) for name in control_names]
|
system_probes = list(await asyncio.gather(*(resolve_system(name, timeout) for name in control_names)))
|
||||||
doh_probes: list[ResolverProbe] = []
|
doh_tasks = [
|
||||||
for name in control_names:
|
resolve_doh(client, ep.name, ep.url, name, timeout)
|
||||||
doh_probes.extend(
|
for name in control_names
|
||||||
await asyncio.gather(
|
for ep in doh_endpoints
|
||||||
*(resolve_doh(client, ep.name, ep.url, name, timeout) for ep in doh_endpoints)
|
]
|
||||||
)
|
doh_probes = list(await asyncio.gather(*doh_tasks))
|
||||||
)
|
|
||||||
|
|
||||||
divergences: list[str] = []
|
divergences: list[str] = []
|
||||||
for system_probe in system_probes:
|
for system_probe in system_probes:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue