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

Function poll_start_task

scripts/issue_good_first_issue_check_openhands.py:256–278  ·  view source on GitHub ↗
(
    start_task_id: str, poll_interval_seconds: int, max_wait_seconds: int
)

Source from the content-addressed store, hash-verified

254
255
256def poll_start_task(
257 start_task_id: str, poll_interval_seconds: int, max_wait_seconds: int
258) -> dict[str, Any]:
259 deadline = time.time() + max_wait_seconds
260 while time.time() < deadline:
261 payload = request_json(
262 OPENHANDS_BASE_URL,
263 f'/api/v1/app-conversations/start-tasks?ids={urllib.parse.quote(start_task_id)}',
264 headers={'Authorization': openhands_headers()['Authorization']},
265 )
266 item = extract_first_item(payload)
267 if item is None:
268 time.sleep(poll_interval_seconds)
269 continue
270 status = item.get('status')
271 if status == 'READY' and item.get('app_conversation_id'):
272 return item
273 if status in {'ERROR', 'FAILED'}:
274 raise RuntimeError(f'OpenHands start task failed: {json.dumps(item)}')
275 time.sleep(poll_interval_seconds)
276 raise TimeoutError(
277 f'Timed out waiting for start task {start_task_id} to become ready'
278 )
279
280
281def 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