(
start_task_id: str, poll_interval_seconds: int, max_wait_seconds: int
)
| 277 | |
| 278 | |
| 279 | def 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 | |
| 304 | def poll_conversation( |
no test coverage detected