| 686 | return self._session.sandbox |
| 687 | |
| 688 | def __enter__(self) -> Sandbox: |
| 689 | client = SandboxClient.from_active_cluster( |
| 690 | cluster=self._cluster, |
| 691 | timeout=self._timeout, |
| 692 | auto_refresh=self._auto_refresh, |
| 693 | write_back=self._write_back, |
| 694 | insecure=self._insecure, |
| 695 | ) |
| 696 | self._client = client |
| 697 | |
| 698 | if self._sandbox_input is None: |
| 699 | self._session = client.create_session(spec=self._spec) |
| 700 | elif isinstance(self._sandbox_input, SandboxRef): |
| 701 | self._session = SandboxSession(client, self._sandbox_input) |
| 702 | else: |
| 703 | self._session = client.get_session(self._sandbox_input) |
| 704 | |
| 705 | ready = client.wait_ready( |
| 706 | self._session.sandbox.name, |
| 707 | timeout_seconds=self._ready_timeout_seconds, |
| 708 | ) |
| 709 | self._session = SandboxSession(client, ready) |
| 710 | |
| 711 | return self |
| 712 | |
| 713 | def __exit__(self, *args: object) -> None: |
| 714 | try: |