Skip to main content

jupygate

jupygate starts, stops, and restarts Jupyter kernels through a small HTTP API. It multiplexes each kernel’s zmq channels over one websocket connection per client. It implements the standard Jupyter kernel REST API and legacy Jupyter websocket message protocol. Existing Jupyter-compatible clients work unchanged. It has no files API, kernelspec lookup, or HTML interface. It is a small, readable alternative to running jupyter_server or kernel_gateway for the one job of hosting kernels.

The gateway manages kernel connections and client messages as follows:

  • Each kernel’s websocket clients share one persistent set of zmq channels owned by the gateway. This avoids jupyter_server’s per-connection readiness checks, buffering handoffs, and associated reconnect races.
  • Kernels implementing JEP 65, including ipymini and recent ipykernel versions, send iopub_welcome when an iopub subscription is ready. The gateway then completes a kernel_info round trip. Kernels without welcome support use jupyter_client-style retries. Both paths use the same readiness check with a timeout.
  • Each client uses its own session id. The gateway routes shell, control, and stdin messages using parent_header.session. It broadcasts iopub messages to all connected clients. The kernel’s HMAC key stays in the gateway. Clients authenticate with a token at the HTTP/websocket layer.
  • The gateway limits queued iopub output for each connected client. It drops excess output when the queue fills and retains status messages. Clients can still track the kernel’s busy/idle state during an output flood.

The source, documentation, and tests are together in one nbdev notebook, core. It covers both websocket encodings, kernel processes, zmq channels and readiness checks, message routing and broadcasts, and the HTTP/websocket server, in dependency order.

Install

pip install jupygate

Install a Jupyter kernel too. The examples use ipymini.

Use

Start a local gateway:

jupygate --port 8787

Create and manage kernels through HTTP:

curl -X POST localhost:8787/api/kernels          # -> {"id": "...", ...}
curl localhost:8787/api/kernels                  # list kernels
curl -X POST localhost:8787/api/kernels/ID/interrupt
curl -X DELETE localhost:8787/api/kernels/ID

Replace ID with the kernel id returned by the API. Connect a websocket to /api/kernels/ID/channels?session_id=... to exchange messages with that kernel. Send Jupyter message dicts with a channel key. The wire-formats section of core describes the encodings.

Kernel creation accepts launch parameters in the POST body:

  • argv: the command to run, with {connection_file} as a placeholder for the kernel connection file.
  • env: the process environment.
  • cwd: the working directory.
  • username: the user account to run the kernel under, using sudo or a configured helper such as gosu.

Kernel creation can run arbitrary commands on the server. Set an authentication token before exposing the gateway to other machines:

jupygate --port 8787 --token S

Replace S with your token. Clients must supply it in an Authorization: token S header or a token=S query parameter on HTTP and websocket requests.

To run the gateway from Python:

from jupygate.core import create_app, serve
serve(create_app(auth_token='S'), port=8787)

The CLI creates ~/.local/state/jupygate/reload/r.py at startup. Touch this file after upgrading jupygate or a kernel package to restart the gateway with the new code. Restarting stops all kernels. Pass --reload to also restart when the package source changes during development. The Python serve() function does not watch for changes.

Metadata

Release files for jupygate 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jupygate 0.0.5
File Size Uploaded Provenance Actions
jupygate-0.0.5.tar.gz 23.3 kB Without provenance Details for jupygate-0.0.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for jupygate 0.0.5
File Interpreter ABI Platform Actions
jupygate-0.0.5-py3-none-any.whl Python 3 none any Details for jupygate-0.0.5-py3-none-any.whl

Total release size: 42.3 kB

Release files / jupygate-0.0.5.tar.gz

Download URL jupygate-0.0.5.tar.gz
Size 23.3 kB
Tags Source
SHA-256 checksum
How to use checksums
2d634f7e443a1f9b90aa238a06aee5c6459719077d0bade9da2e47526271d020
BLAKE2b-256 checksum
How to use checksums
592815b97f22943e07f803d41c672923b574d2e5cfefefb3e488004716e1c42c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Release files / jupygate-0.0.5-py3-none-any.whl

Download URL jupygate-0.0.5-py3-none-any.whl
Size 19.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1dadad93eb80df5fba15e40de86a98dc8e05c6fbe04ad64e83ef514a34cdd1fc
BLAKE2b-256 checksum
How to use checksums
0085b70bf7dcee3ce4f85b986360874d32ca848cdf655fd8721841f5b78cfa49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Security for jupygate 0.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page