Final check after polling loop.
(
self,
request_id: str,
instance_id: str | None,
waited_ms: int,
)
| 557 | return self._validate_waited_instance(request_id, instance_id, waited_ms) |
| 558 | |
| 559 | def _validate_waited_instance( |
| 560 | self, |
| 561 | request_id: str, |
| 562 | instance_id: str | None, |
| 563 | waited_ms: int, |
| 564 | ) -> UnityInstance | dict[str, Any]: |
| 565 | """Final check after polling loop.""" |
| 566 | result = self._get_instance_or_error(request_id, instance_id) |
| 567 | if isinstance(result, dict): |
| 568 | return result |
| 569 | if result is None: |
| 570 | return ErrorMessage.from_code( |
| 571 | request_id, |
| 572 | ErrorCode.INSTANCE_NOT_FOUND, |
| 573 | f"Instance not found after waiting {waited_ms}ms. Ensure Unity Editor has UnityBridge connected. Check with 'u instances'.", |
| 574 | ).to_dict() |
| 575 | if self._instance_needs_wait(result): |
| 576 | status_label = result.status.value if hasattr(result.status, "value") else str(result.status) |
| 577 | error_code = ( |
| 578 | ErrorCode.INSTANCE_RELOADING |
| 579 | if result.status == InstanceStatus.RELOADING |
| 580 | else ErrorCode.INSTANCE_DISCONNECTED |
| 581 | if result.status == InstanceStatus.DISCONNECTED |
| 582 | else ErrorCode.INSTANCE_NOT_FOUND |
| 583 | ) |
| 584 | return ErrorMessage.from_code( |
| 585 | request_id, |
| 586 | error_code, |
| 587 | f"Instance not ready after {waited_ms}ms: {result.instance_id} ({status_label}). Retry after a few seconds.", |
| 588 | ).to_dict() |
| 589 | if waited_ms > 0: |
| 590 | logger.info(f"[{request_id}] Instance ready after {waited_ms}ms wait") |
| 591 | return result |
| 592 | |
| 593 | def _should_wait_for_missing( |
| 594 | self, |
no test coverage detected