Skip to content

async-kernel

pypi downloads CI Ruff uv basedpyright - checked Built with Material for MkDocs codecov

logo-svg

async-kernel provides Python Jupyter kernels and clients compatible with CPython (Jupyter & VS code) and Pyodide (Jupyterlite).

The kernel interface supports multiple connections including:

  1. Messaging via ZMQ sockets (Jupyter, VS Code, etc).
  2. Same-process local client enabling (Jupyterlite) and user access.

Highlights

  • Built using aiologic thread-safe synchronisation primitives.
  • The Caller class provides a powerful but simple interface for cross-thread code execution in asyncio and trio backends, with guest event loop support built in.
  • A zmq poll event loop for thread-safe zmq sockets.
  • IPython shell
    • top-level await ('asyncio' or 'trio' backend) in cells
    • async magic function support in cells
  • Per-subshell user_ns
  • GUI event loops 1
    • inline
    • ipympl
    • tk host and asyncio2 or trio3 backend running as a guest
    • qt host and asyncio2 or trio3 backend running as a guest
  • Experimental support for Jupyterlite (try it online here 👈)
    • %pip install magic (using micropip)
  • Debugger client
  • Local client.
  • ZMQ client.

Installation

pip install async-kernel

Kernelspecs

A kernelspec with the name 'async' is added when async-kernel is installed.

Kernel specs can be installed/uninstalled via the command line.

async-kernel install

# To install for a user
async-kernel install --user

For further detail about kernel spec customisation see command line and kernel configuration and custom kernel.ipynb.

Faster data serialization

orjson (a fast JSON library) is supported and will be used by default if it has been installed.

Free-threading support

async-kernel's Caller's are thread-local and it's methods are internally synchronised4.

Origin

async-kernel started as a fork of IPyKernel. Thank you to the original contributors of IPyKernel that made async-kernel possible.


  1. A gui (host) enabled kernel interface starts a gui's mainloop (host) which starts the backend as a guest, then finally the Kernel is started. 

  2. The asyncio implementation of start_guest_run was written by the author of aiologic and provided as a gist

  3. trio's start_guest_run

  4. free threading terminology