-
-
Notifications
You must be signed in to change notification settings - Fork 384
feat: Run exec_request inside a task #1384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…ute_request in separate task
Thanks @fleming79. |
6e33f7d
to
5f71eaa
Compare
… processing shell messages.
@davidbrochart - thank you for the review and positive feedback! I've updated the code so it will now cancel all requests where the submitted (monotonic) time is prior to the aborted time. |
…l_control_messages
…e kernel and drop old integration code.
… for non-execute requests.
Here is a demo video showing a forked version of ipylab using await extensively. The modified version of ipylab defines async functions to communicate with the frontend via custom widget messages ( ipylab.async.everywhere.demo.mp4 |
@davidbrochart - Hoping you can find time to review this PR. Relevent: |
Thanks a lot for your work in this PR @fleming79, this looks really interesting. |
All tests pass locally except those that get skipped for some reason in the "inprocess" folder. |
@davidbrochart @minrk @krassowski @ianthomas23 @Carreau Dear all, I've drafted a stripped down version of ipykernel starting from this PR and am contacting you seeking feedback/advice. For the moment I've called it The motivation was to provide an asynchronous native kernel enabling comms to pass whilst a cell is busy awaiting a result. It does this by queuing non-silent execute_requests and running them in a designated task. Silent execute requests are run in their own tasks and are non-cancellable. To try it out you can pip install it from the source: asynckernel-0.0.0a1.tar.gz Untitled.video.-.Made.with.Clipchamp.3.mp4Test codeimport anyio
from ipywidgets import IntSlider, HTML, __version__
import time
slider = IntSlider()
value = HTML()
print('ipywidgets', __version__)
display(slider)
display(value)
async def run_till_100():
while True:
await anyio.sleep(0.1)
value.value = str(slider.value)
if slider.value == 100:
return 'Done'
print(await run_till_100()) |
This PR modifies the kernel to run exec_requests inside a task using Memory object streams to queue pending tasks. This means that other shell messages can be processed while the execution request is being processed.
ref: jupyterlab/jupyterlab#17363 (comment)
New features
start_soon
method to the kernel providing a thread safe equivalent to anyio.start_soon.Breaking changes
set_parent
&get_parent
methods are removed. Instead the parent message is only set for the current execute request providing better certainty for inputs and outputsKnown issues
Example
Screenshot
Before
ipykernel.demo.before.mp4
After
ipykernel.demo.after.mp4
Notebook code
Requires: