List all the kernels :param timeout: Timeout for the call :return: List of kernel ids
(self, timeout: Optional[float] = TIMEOUT)
| 163 | raise KernelException(f"Failed to shutdown kernel {kernel_id}") |
| 164 | |
| 165 | def list_kernels(self, timeout: Optional[float] = TIMEOUT) -> List[str]: |
| 166 | """ |
| 167 | List all the kernels |
| 168 | :param timeout: Timeout for the call |
| 169 | :return: List of kernel ids |
| 170 | """ |
| 171 | response = requests.get( |
| 172 | f"{self._sandbox.get_protocol()}://{self._sandbox.get_hostname(8888)}/api/kernels", |
| 173 | timeout=timeout, |
| 174 | ) |
| 175 | if not response.ok: |
| 176 | raise KernelException(f"Failed to list kernels: {response.text}") |
| 177 | return [kernel["id"] for kernel in response.json()] |
| 178 | |
| 179 | def close(self): |
| 180 | """ |