| 755 | ) |
| 756 | |
| 757 | def exec_python( |
| 758 | self, |
| 759 | function: Callable[..., object], |
| 760 | *, |
| 761 | args: Sequence[object] = (), |
| 762 | kwargs: Mapping[str, object] | None = None, |
| 763 | stream_output: bool = False, |
| 764 | workdir: str | None = None, |
| 765 | env: Mapping[str, str] | None = None, |
| 766 | timeout_seconds: int | None = None, |
| 767 | ) -> ExecResult: |
| 768 | if self._session is None: |
| 769 | raise SandboxError("sandbox context has not been entered") |
| 770 | return self._session.exec_python( |
| 771 | function, |
| 772 | args=args, |
| 773 | kwargs=kwargs, |
| 774 | stream_output=stream_output, |
| 775 | workdir=workdir, |
| 776 | env=env, |
| 777 | timeout_seconds=timeout_seconds, |
| 778 | ) |
| 779 | |
| 780 | |
| 781 | _PYTHON_CLOUDPICKLE_BOOTSTRAP = ( |