mirror of
https://github.com/Horizontal42/netsleuth.git
synced 2026-11-10 15:42:10 +03:00
Refactor collect_path_diversity to run probes concurrently using asyncio.gather. (#25)
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
This commit is contained in:
parent
67f677a536
commit
03d54b900c
1 changed files with 5 additions and 3 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import asyncio
|
||||||
import re
|
import re
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
|
|
@ -158,8 +159,9 @@ async def collect_path_diversity(
|
||||||
timeout: float,
|
timeout: float,
|
||||||
source_ip: str | None = None,
|
source_ip: str | None = None,
|
||||||
) -> PathDiversity:
|
) -> PathDiversity:
|
||||||
hops = [
|
coros = [
|
||||||
await probe_edge(client, host, timeout=timeout, source_ip=source_ip)
|
probe_edge(client, host, timeout=timeout, source_ip=source_ip)
|
||||||
for _label, host in targets[:max_targets]
|
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))
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue