MCPcopy Index your code
hub / github.com/AutoForgeAI/autoforge / poll_progress

Function poll_progress

server/websocket.py:687–718  ·  view source on GitHub ↗

Poll database for progress changes and send updates.

(websocket: WebSocket, project_name: str, project_dir: Path)

Source from the content-addressed store, hash-verified

685manager = ConnectionManager()
686
687async def poll_progress(websocket: WebSocket, project_name: str, project_dir: Path):
688 """Poll database for progress changes and send updates."""
689 count_passing_tests = _get_count_passing_tests()
690 last_passing = -1
691 last_in_progress = -1
692 last_total = -1
693
694 while True:
695 try:
696 passing, in_progress, total = count_passing_tests(project_dir)
697
698 # Only send if changed
699 if passing != last_passing or in_progress != last_in_progress or total != last_total:
700 last_passing = passing
701 last_in_progress = in_progress
702 last_total = total
703 percentage = (passing / total * 100) if total > 0 else 0
704
705 await websocket.send_json({
706 "type": "progress",
707 "passing": passing,
708 "in_progress": in_progress,
709 "total": total,
710 "percentage": round(percentage, 1),
711 })
712
713 await asyncio.sleep(2) # Poll every 2 seconds
714 except asyncio.CancelledError:
715 raise
716 except Exception as e:
717 logger.warning(f"Progress polling error: {e}")
718 break
719
720
721async def project_websocket(websocket: WebSocket, project_name: str):

Callers 1

project_websocketFunction · 0.85

Calls 2

count_passing_testsFunction · 0.90
_get_count_passing_testsFunction · 0.85

Tested by

no test coverage detected