MCPcopy Create free account
hub / github.com/OpenHands/OpenHands / poll_start_task

Function poll_start_task

scripts/issue_duplicate_check_openhands.py:279–301  ·  view source on GitHub ↗
(
    start_task_id: str, poll_interval_seconds: int, max_wait_seconds: int
)

Source from the content-addressed store, hash-verified

277
278
279def poll_start_task(
280 start_task_id: str, poll_interval_seconds: int, max_wait_seconds: int
281) -> dict[str, Any]:
282 deadline = time.time() + max_wait_seconds
283 while time.time() < deadline:
284 payload = request_json(
285 OPENHANDS_BASE_URL,
286 f'/api/v1/app-conversations/start-tasks?ids={urllib.parse.quote(start_task_id)}',
287 headers={'Authorization': openhands_headers()['Authorization']},
288 )
289 item = extract_first_item(payload)
290 if item is None:
291 time.sleep(poll_interval_seconds)
292 continue
293 status = item.get('status')
294 if status == 'READY' and item.get('app_conversation_id'):
295 return item
296 if status in {'ERROR', 'FAILED'}:
297 raise RuntimeError(f'OpenHands start task failed: {json.dumps(item)}')
298 time.sleep(poll_interval_seconds)
299 raise TimeoutError(
300 f'Timed out waiting for start task {start_task_id} to become ready'
301 )
302
303
304def poll_conversation(

Callers 1

mainFunction · 0.70

Calls 4

request_jsonFunction · 0.70
openhands_headersFunction · 0.70
extract_first_itemFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected