fix: 探测整批代理加上总时限,学时翻页先判重再累加
This commit is contained in:
@@ -31,6 +31,7 @@ LATENCY_LIMIT = 3.0
|
||||
LATENCY_LIMIT_MS = 3000
|
||||
PROBE_CONCURRENCY = 16
|
||||
MAX_PROBES = 80
|
||||
PROBE_BATCH_TIMEOUT = 20.0
|
||||
ALIVE_REPROBE_SLOTS = 20
|
||||
MAX_SWITCHES = 8
|
||||
PROBE_URL = EUNIV + "/"
|
||||
@@ -558,18 +559,24 @@ def _probe_many(nodes: list[tuple[int, str, str, int]]) -> list[tuple[int, bool,
|
||||
return []
|
||||
workers = min(PROBE_CONCURRENCY, len(nodes))
|
||||
results: list[tuple[int, bool, int, str]] = []
|
||||
with ThreadPoolExecutor(max_workers=workers) as pool:
|
||||
pool = ThreadPoolExecutor(max_workers=workers)
|
||||
try:
|
||||
futures = {
|
||||
pool.submit(probe, scheme, host, port): node_id
|
||||
for node_id, scheme, host, port in nodes
|
||||
}
|
||||
for future in as_completed(futures):
|
||||
node_id = futures[future]
|
||||
try:
|
||||
ok, latency, reason = future.result()
|
||||
except Exception as exc:
|
||||
ok, latency, reason = False, 0, _short_reason(exc)
|
||||
results.append((node_id, ok, latency, reason))
|
||||
try:
|
||||
for future in as_completed(futures, timeout=PROBE_BATCH_TIMEOUT):
|
||||
node_id = futures[future]
|
||||
try:
|
||||
ok, latency, reason = future.result()
|
||||
except Exception as exc:
|
||||
ok, latency, reason = False, 0, _short_reason(exc)
|
||||
results.append((node_id, ok, latency, reason))
|
||||
except TimeoutError:
|
||||
pass
|
||||
finally:
|
||||
pool.shutdown(wait=False, cancel_futures=True)
|
||||
return results
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user