> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mage.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Python kernels

> Configure Python kernel execution in the pipeline editor.

1. [Python3](#python3)
2. [Multi-user kernels in Mage Pro](#multi-user-kernels)
3. [Restart kernel](#restart-kernel)

## Python3 kernel <a name="python3" />

Python3 is the default kernel. You can prototype and transform small to medium
size datasets with this kernel. Pipelines built with this kernel can be executed
in Python environments.

## Multi-user kernels in Mage Pro <a name="multi-user-kernels" />

Mage Pro can run a separate Python kernel for each authenticated user in the
pipeline editor. This lets multiple users run blocks at the same time without
sharing one notebook kernel, execution queue, or output stream.

Enable the feature by setting the following environment variable on your Mage
Pro cluster:

```bash theme={"system"}
MULTI_USER_JUPYTER_KERNELS=1
```

When this setting is enabled:

* Each authenticated user gets an isolated Python kernel for interactive block
  execution from the pipeline editor.
* Kernel output is routed only to websocket clients for the user that started
  the block run.
* Interrupt and restart actions apply to the current user's kernel.
* Idle kernels without connected websocket clients are cleaned up automatically.

You can tune resource cleanup with:

| Variable                              | Description                                                                                                           | Default |
| ------------------------------------- | --------------------------------------------------------------------------------------------------------------------- | ------- |
| `JUPYTER_KERNEL_IDLE_TIMEOUT_SECONDS` | Number of seconds an inactive user kernel can stay alive after its websocket clients disconnect.                      | `1800`  |
| `JUPYTER_KERNEL_MAX_PER_SERVER`       | Maximum number of user kernels to keep on one Mage server. When the limit is reached, Mage evicts idle kernels first. | `50`    |

For debugging, admins can list all active user kernels with:

```bash theme={"system"}
GET /api/kernels?include_all=1
```

By default, `GET /api/kernels` only returns the kernel for the current user.

<Note>
  Multi-user Jupyter kernels are a Mage Pro feature. Mage uses the Python3 kernel
  for this mode; the legacy PySpark notebook kernel is not supported.
</Note>

## Restart kernel

If your block execution is hanging in the notebook and no block output is
printed, you can try interrupting the block execution and restarting the kernel.
You can find the "Restart kernel" button in the "Run" menu at the top of the
notebook.
