(
start_task_id: str, poll_interval_seconds: int, max_wait_seconds: int
)
| 254 | |
| 255 | |
| 256 | def 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 | |
| 281 | def poll_conversation( |
no test coverage detected