Spaces:
Paused
Paused
Run mount probes in parallel to avoid proxy idle timeout
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import base64
|
| 2 |
import socket
|
| 3 |
import time
|
|
|
|
| 4 |
from datetime import datetime, timezone
|
| 5 |
|
| 6 |
import gradio as gr
|
|
@@ -76,19 +77,27 @@ def run_checks():
|
|
| 76 |
"|---|-------|------|-----------:|-------------:|--------|",
|
| 77 |
]
|
| 78 |
|
| 79 |
-
yield f"{header}\n\n⏳ Probing {len(MOUNTS)} mount points (~{READ_SECONDS}s
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
)
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
|
| 93 |
|
| 94 |
DARK_THEME = gr.themes.Base(
|
|
|
|
| 1 |
import base64
|
| 2 |
import socket
|
| 3 |
import time
|
| 4 |
+
from concurrent.futures import ThreadPoolExecutor, as_completed
|
| 5 |
from datetime import datetime, timezone
|
| 6 |
|
| 7 |
import gradio as gr
|
|
|
|
| 77 |
"|---|-------|------|-----------:|-------------:|--------|",
|
| 78 |
]
|
| 79 |
|
| 80 |
+
yield f"{header}\n\n⏳ Probing {len(MOUNTS)} mount points in parallel (~{READ_SECONDS}s)…"
|
| 81 |
+
|
| 82 |
+
rows_by_idx: dict[int, str] = {}
|
| 83 |
+
with ThreadPoolExecutor(max_workers=len(MOUNTS)) as ex:
|
| 84 |
+
futures = {
|
| 85 |
+
ex.submit(probe_mount, mount_id, USER, PASS): (i, mount_id, name)
|
| 86 |
+
for i, (mount_id, name) in enumerate(MOUNTS)
|
| 87 |
+
}
|
| 88 |
+
for future in as_completed(futures):
|
| 89 |
+
i, mount_id, name = futures[future]
|
| 90 |
+
r = future.result()
|
| 91 |
+
icon = ICON.get(r["status"], "?")
|
| 92 |
+
rows_by_idx[i] = (
|
| 93 |
+
f"| {icon} | `{mount_id}` | {name} | "
|
| 94 |
+
f"{r['bytes']} | {r['rtcm']} | {r['detail']} |"
|
| 95 |
+
)
|
| 96 |
+
ordered = [rows_by_idx[j] for j in sorted(rows_by_idx)]
|
| 97 |
+
partial = "\n".join([header, "", *table_header, *ordered])
|
| 98 |
+
if len(rows_by_idx) < len(MOUNTS):
|
| 99 |
+
partial += f"\n\n⏳ {len(rows_by_idx)}/{len(MOUNTS)} done…"
|
| 100 |
+
yield partial
|
| 101 |
|
| 102 |
|
| 103 |
DARK_THEME = gr.themes.Base(
|