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

Function poll_conversation

scripts/issue_duplicate_check_openhands.py:304–329  ·  view source on GitHub ↗
(
    app_conversation_id: str, poll_interval_seconds: int, max_wait_seconds: int
)

Source from the content-addressed store, hash-verified

302
303
304def poll_conversation(
305 app_conversation_id: str, poll_interval_seconds: int, max_wait_seconds: int
306) -> dict[str, Any]:
307 deadline = time.time() + max_wait_seconds
308 while time.time() < deadline:
309 payload = request_json(
310 OPENHANDS_BASE_URL,
311 f'/api/v1/app-conversations?ids={urllib.parse.quote(app_conversation_id)}',
312 headers={'Authorization': openhands_headers()['Authorization']},
313 )
314 item = extract_first_item(payload)
315 if item is None:
316 time.sleep(poll_interval_seconds)
317 continue
318 execution_status = str(item.get('execution_status', '')).lower()
319 if execution_status in FAILED_EXECUTION_STATUSES:
320 raise RuntimeError(
321 'OpenHands conversation ended with '
322 f'{execution_status}: {json.dumps(item)}'
323 )
324 if execution_status in SUCCESSFUL_TERMINAL_EXECUTION_STATUSES:
325 return item
326 time.sleep(poll_interval_seconds)
327 raise TimeoutError(
328 f'Timed out waiting for conversation {app_conversation_id} to finish running'
329 )
330
331
332def validate_event_search_results(events: list[dict[str, Any]]) -> list[dict[str, Any]]:

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