MCPcopy
hub / github.com/htdt/godogen / poll_task

Function poll_task

asset-gen/tools/tripo3d.py:104–117  ·  view source on GitHub ↗
(task_id: str, timeout: int = 600, interval: int = 5)

Source from the content-addressed store, hash-verified

102
103
104def poll_task(task_id: str, timeout: int = 600, interval: int = 5) -> dict:
105 start = time.time()
106 url = f"{API_BASE}/task/{task_id}"
107 while time.time() - start < timeout:
108 resp = requests.get(url, headers=_headers())
109 resp.raise_for_status()
110 data = resp.json()["data"]
111 status = data["status"]
112 if status == "success":
113 return data
114 if status in ("failed", "cancelled", "unknown"):
115 raise RuntimeError(f"Task {task_id} {status}: {data}")
116 time.sleep(interval)
117 raise TimeoutError(f"Task {task_id} timed out after {timeout}s")
118
119
120def download_model(task_result: dict, output_path: Path) -> Path:

Callers 5

cmd_glbFunction · 0.90
cmd_rigFunction · 0.90
cmd_retargetFunction · 0.90
cmd_resumeFunction · 0.90
image_to_glbFunction · 0.85

Calls 1

_headersFunction · 0.85

Tested by

no test coverage detected