Skip to main content

Guides

Interrupting the Kernel

When executing a long-running cell using the %%ag command, you might need to interrupt the operation due to complex computations, large datasets, or unexpected infinite loops. This can be done using keyboard shortcuts.

Kernel Interruption Precautions

If you have initiated a long-running process and want to stop it mid-way, interrupting the kernel is your go-to solution. However, use this approach carefully since it abruptly stops the process, which might lead to unpredictable results if the process is modifying a shared state.

Keyboard Shortcuts

Before using the keyboard shortcuts, ensure you are not in edit mode for any cell. You can exit edit mode by pressing the Esc key. The cell border should change from green to blue in Jupyter Notebook and Google Colab, indicating that you are in Command mode. For different environments, the keyboard shortcuts to interrupt a running cell are:

  • Jupyter Notebook: Press the I key twice.
  • VSCode: Use the stop icon in the Python Interactive window.
  • Google Collab: Press the keys Ctrl + M I

Using one of the above approaches, you will stop the current execution. In addition, the Kernel interrupted successfully will be displayed.