Skip to main content

jupygate

jupygate starts, stops, and restarts Jupyter kernels over a small HTTP API, and muxes each kernel’s zmq channels over one websocket per client. It speaks the standard Jupyter kernels REST shape and the legacy Jupyter websocket message protocol, so existing Jupyter-compatible clients work unchanged. It deliberately has no files API (manage files by running Python in a kernel), no kernelspecs (clients say exactly what to launch), and no HTML.

It is a small, readable alternative to running jupyter_server or kernel_gateway for the one job of hosting kernels. kernel_gateway is a thin skin over jupyter_server’s websocket bridge; jupygate replaces the bridge itself with a simpler architecture:

  • One persistent zmq channel set per kernel, owned by the gateway, instead of fresh streams per websocket connection. Clients connect and drop without touching zmq, which deletes jupyter_server’s per-connect “nudge” dance, buffering handoffs, and reconnect races.
  • Welcome-based readiness: kernels that implement JEP 65 (ipymini, modern ipykernel) greet each iopub subscription with iopub_welcome, so readiness is one bounded wait plus one kernel_info round trip. Kernels without it get jupyter_client-style retries - same loop, it just can’t short-circuit.
  • Replies route by session: each client signs with its own session id; parent_header.session routes shell, control, and stdin traffic back to the requester. iopub is broadcast. The kernel’s HMAC key never leaves the gateway - client auth is a bearer token at the HTTP/websocket layer.
  • Explicit overflow policy: each client has a bounded queue that never drops status, so a flooded client still sees a truthful busy/idle picture.

One nbdev notebook, core, builds it bottom-up - wire formats (the two websocket encodings), kernel processes, channels (the zmq side and the ready-wait), the mux (routing and fan-out), and the gateway server (the HTTP/websocket surface) - and is source, docs, and tests at once.

Install

pip install jupygate

Plus at least one kernel; the examples use ipymini.

Use

Serve a gateway:

jupygate --port 8787            # open, for localhost use
jupygate --port 8787 --token S  # every request must carry the token

The gateway watches a touch file, ~/.local/state/jupygate/reload/r.py (created at startup): touching it restarts the gateway with new code, killing all kernels - the deliberate restart lever after upgrading jupygate or a kernel package. --reload additionally restarts on package source changes, for development.

Then from any HTTP client:

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

and connect a websocket to /api/kernels/ID/channels?session_id=... speaking the standard Jupyter message dicts with a channel key (see the wire-formats section of core). Kernel creation accepts explicit launch parameters in the POST body - argv (with {connection_file} placeholder), env, cwd, and username for a sudo/gosu wrap - which is also why a non-localhost deployment should set a token: this API runs arbitrary commands by design, exactly like any Jupyter kernel server.

In Python, the same thing programmatically:

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jupygate-0.0.2.tar.gz (23.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jupygate-0.0.2-py3-none-any.whl (19.2 kB view details)

Uploaded Python 3

File details

Details for the file jupygate-0.0.2.tar.gz.

File metadata

  • Download URL: jupygate-0.0.2.tar.gz
  • Upload date:
  • Size: 23.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.2

File hashes

Hashes for jupygate-0.0.2.tar.gz
Algorithm Hash digest
SHA256 01fcae81b957aefb9aec5b7c5e8d480cf026010123f2201cd870bf88f25ddb24
MD5 eb70ba189c77f3f68216e92ff0e0f0e4
BLAKE2b-256 5ff7849e49a4a7517d5669cf019317fc5ff88f278b405f30c67a92433ef75240

See more details on using hashes here.

File details

Details for the file jupygate-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: jupygate-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 19.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.2

File hashes

Hashes for jupygate-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0efb2398c87debbbecda5878fcd82fcb246e4399c688ecae362fa3e0df8bc17e
MD5 54ffdf144970679f5305b13da62798e9
BLAKE2b-256 e01f25869f9c01753cf82b38f5b6640cac570f9d8f9dfb14e24191d1020e0d90

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page