A concurrent python kernel for Jupyter supporting AnyIO, AsyncIO and Trio.
Project description
Async kernel
Async kernel is a Python Jupyter kernel with concurrent message handling.
Messages are processed fairly whilst preventing asynchronous deadlocks by using a unique message handler per channel, message_type and subshell_id.
Highlights
- Experimental support for Jupyterlite try it online here 👈
- Debugger client
- anyio compatible event loops
- aiologic thread-safe synchronisation primitives
- Easy multi-thread / multi-event loop management
- IPython shell
- Per-subshell user_ns
- GUI event loops
- inline
- ipympl
- tk
- qt
Installation
pip install async-kernel
Asyncio
An asyncio kernel based backend with the name 'async' is installed when the kernel is installed.
Trio backend
To add a kernel spec for a trio backend.
pip install trio
async-kernel -a async-trio --interface.backend=trio
For further detail about kernel spec customisation see command line usage.
Message handling
-
When a message is received the
msg_handleris called with:- 'job' (a dict of
msg,received_timeandident) - The
channel msg_type- A function
send_reply
- 'job' (a dict of
-
The
msg_handler- determines the
subshell_idand run mode. - obtains the
handlerfrom the kernel with the same name as themsg_type. - determines the run mode
- creates cached version of the
run_handlerwith a unique version per:- The
handler channelsubshell_id- send_reply (constant or per-channel)
- The
- Obtains the caller associated with the channel and schedules execution of the cached handler
- determines the
Run mode
The run modes available are:
RunMode.direct→Caller.call_direct: Run the request directly in the scheduler.RunMode.queue→Caller.queue_call: Run the request in a queue dedicated to the subshell, handler & channel.RunMode.task→Caller.call_soon: Run the request in a separate task.RunMode.thread→Caller.to_thread: Run the request in a separate worker thread.
These are the currently assigned run modes.
| SocketID | shell | control |
|---|---|---|
| comm_close | direct | direct |
| comm_info_request | direct | direct |
| comm_msg | queue | queue |
| comm_open | direct | direct |
| complete_request | thread | thread |
| create_subshell_request | None | thread |
| debug_request | None | queue |
| delete_subshell_request | None | thread |
| execute_request | queue | queue |
| history_request | thread | thread |
| inspect_request | thread | thread |
| interrupt_request | direct | direct |
| is_complete_request | thread | thread |
| kernel_info_request | direct | direct |
| list_subshell_request | None | direct |
| shutdown_request | None | direct |
Origin
Async kernel started as a fork of IPyKernel. Thank you to the original contributors of IPyKernel that made Async kernel possible.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file async_kernel-0.12.2.tar.gz.
File metadata
- Download URL: async_kernel-0.12.2.tar.gz
- Upload date:
- Size: 288.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1747bb8089987be0e5428b57f64f78d128c5eda6527aab19f59276cb5d05bc71
|
|
| MD5 |
b39332483edfaa70626f81f260f09429
|
|
| BLAKE2b-256 |
d2b818bb510f1c94ae0d8334cf9a831648201b66cced75e9e84421e24236dff2
|
Provenance
The following attestation bundles were made for async_kernel-0.12.2.tar.gz:
Publisher:
publish-to-pypi.yml on fleming79/async-kernel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
async_kernel-0.12.2.tar.gz -
Subject digest:
1747bb8089987be0e5428b57f64f78d128c5eda6527aab19f59276cb5d05bc71 - Sigstore transparency entry: 935203404
- Sigstore integration time:
-
Permalink:
fleming79/async-kernel@406776a455106c807c73408fcdad4aa1b43e09ae -
Branch / Tag:
refs/heads/main - Owner: https://github.com/fleming79
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@406776a455106c807c73408fcdad4aa1b43e09ae -
Trigger Event:
workflow_run
-
Statement type:
File details
Details for the file async_kernel-0.12.2-py3-none-any.whl.
File metadata
- Download URL: async_kernel-0.12.2-py3-none-any.whl
- Upload date:
- Size: 94.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e6044e6124534ff2f47c02f42f1b8caf11aba5d12c51ee354dcd21e2c9e1c4b
|
|
| MD5 |
45f3d69535aa602cbe8d507be16b9207
|
|
| BLAKE2b-256 |
0bf6894c901ecf71e0822eea44c9d6e74f09ff20b6a556d492bb9a51c5650504
|
Provenance
The following attestation bundles were made for async_kernel-0.12.2-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on fleming79/async-kernel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
async_kernel-0.12.2-py3-none-any.whl -
Subject digest:
8e6044e6124534ff2f47c02f42f1b8caf11aba5d12c51ee354dcd21e2c9e1c4b - Sigstore transparency entry: 935203438
- Sigstore integration time:
-
Permalink:
fleming79/async-kernel@406776a455106c807c73408fcdad4aa1b43e09ae -
Branch / Tag:
refs/heads/main - Owner: https://github.com/fleming79
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@406776a455106c807c73408fcdad4aa1b43e09ae -
Trigger Event:
workflow_run
-
Statement type: