-
-
Notifications
You must be signed in to change notification settings - Fork 387
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
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()) |
@fleming79 I presume you have realised that with the recent branch manipulations this now targets the As for my opinion, I expect everyone to be in favour of concurrent async cell execution. I think it likely that it will be supported in The journey from here to there is difficult though. Enabling concurrent cell execution isn't really the issue (it would be trivial on the current What is needed is to canvas the opinions of Jupyter maintainers across the up and downstream projects, not just here in |
@ianthomas23 Thank you kindly for the response and details about how to proceed. I agree with you about breaking downstream projects which is why I'm thinking of a new package. It won't be fully compatible with downstream. Since my previous post about a month ago I've made significant progress on a new kernel. Long story short - it's approaching a state that I would like to make it more widely available. If you're interested to have a look there is some draft documentation here and it can be installed with: pip install -i https://test.pypi.org/simple/ async-kernel I'm thinking on making a release of it as a package on pypi proper and was wondering if you can suggest how I should deal with:
Regarding a JEP - I think maybe something on the lines of 'run modes' might be worth consideration. |
Two cents:
|
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: