@mytec: iter3.4.0 ready for testing

This commit is contained in:
2026-02-02 21:58:03 +02:00
parent 867ee3d0f4
commit 57106df5ae
8 changed files with 742 additions and 19 deletions

View File

@@ -62,6 +62,23 @@ class ConnectionManager:
except Exception as e:
logger.warning(f"[WS] send_error failed: {e}")
async def send_partial_results(
self, ws: WebSocket, calc_id: str,
points: list, tile_idx: int, total_tiles: int,
):
"""Send per-tile partial results for progressive rendering."""
try:
await ws.send_json({
"type": "partial_results",
"calculation_id": calc_id,
"points": [p.model_dump() for p in points],
"tile": tile_idx,
"total_tiles": total_tiles,
"progress": (tile_idx + 1) / total_tiles,
})
except Exception as e:
logger.debug(f"[WS] send_partial_results failed: {e}")
ws_manager = ConnectionManager()
@@ -135,6 +152,12 @@ async def _run_calculation(ws: WebSocket, calc_id: str, data: dict):
await ws_manager.send_progress(ws, calc_id, "Initializing", 0.02)
# ── Tile callback for progressive results (large radius) ──
async def _tile_callback(tile_points, tile_idx, total_tiles):
await ws_manager.send_partial_results(
ws, calc_id, tile_points, tile_idx, total_tiles,
)
# ── Backup progress poller: catches anything call_soon_threadsafe missed ──
async def progress_poller():
last_sent_seq = 0
@@ -165,6 +188,7 @@ async def _run_calculation(ws: WebSocket, calc_id: str, data: dict):
coverage_service.calculate_coverage(
sites[0], settings, cancel_token,
progress_fn=sync_progress_fn,
tile_callback=_tile_callback,
),
timeout=300.0,
)
@@ -173,6 +197,7 @@ async def _run_calculation(ws: WebSocket, calc_id: str, data: dict):
coverage_service.calculate_multi_site_coverage(
sites, settings, cancel_token,
progress_fn=sync_progress_fn,
tile_callback=_tile_callback,
),
timeout=300.0,
)