| 113 | lock = asyncio.Lock() |
| 114 | |
| 115 | async def _one(ip, label): |
| 116 | nonlocal spin |
| 117 | reachable, rtt = await _tcp_ping(ip, TELEGRAM_DC_PORT) |
| 118 | |
| 119 | async with lock: |
| 120 | results.append({"ip": ip, "label": label, "reachable": reachable, "rtt": rtt}) |
| 121 | spin = (spin + 1) % len(_SPIN) |
| 122 | ok = sum(1 for x in results if x["reachable"]) |
| 123 | await display.update(2, f"[dim]{_SPIN[spin]} проверяем {len(results)}/{total} доступно: {ok}[/dim]") |
| 124 | |
| 125 | await asyncio.gather(*[_one(ip, lbl) for ip, lbl in TELEGRAM_DC_IPS]) |
| 126 | |