MCPcopy Create free account
hub / github.com/bigdra50/unity-cli / _validate_waited_instance

Method _validate_waited_instance

relay/server.py:559–591  ·  view source on GitHub ↗

Final check after polling loop.

(
        self,
        request_id: str,
        instance_id: str | None,
        waited_ms: int,
    )

Source from the content-addressed store, hash-verified

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,

Callers 1

_wait_for_instanceMethod · 0.95

Calls 5

_instance_needs_waitMethod · 0.95
from_codeMethod · 0.80
infoMethod · 0.80
to_dictMethod · 0.45

Tested by

no test coverage detected