Skip to content
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

Blocking cell execution waiting for Widget interaction #311

Open
kafonek opened this issue Feb 24, 2018 · 3 comments
Open

Blocking cell execution waiting for Widget interaction #311

kafonek opened this issue Feb 24, 2018 · 3 comments

Comments

@kafonek
Copy link

kafonek commented Feb 24, 2018

Hi all,

I am interested in blocking further cell execution in a Jupyter notebook until some sort of widget interaction has occurred. For instance, letting a user perform a "cell -> run all" command, then displaying a dropdown widget in one cell, and blocking in the next cell until the user has selected an option from that dropdown list.

In a regular notebook setup, widget changes (comm_msg over zeromq) won't be picked up by the kernel because it's blocking until the cell is completely executed. If an Asynchronous Loop is involved, then all cells will be executed (from the "cell -> run all") command immediately if they aren't written in an async fashion.

One option is to override the kernel.shell_handlers functions to 'capture' the execute_request messages coming in on the stream while letting the comm_msg events go through, then to 'replay' the execute_request messages after the fact. If I go with that pattern (example, how do I make the output show up in the output cells for the original input cells instead of all in a single cell where the 'replay' happens?

A second option is to have the ipykernel listen for execute_request and comm_* events on different streams. There's been discussion of that idea (@dsblank @AlexTugarev #65, @jasongrout jupyter/jupyter_client#285), but it doesn't look like the issue has moved forward. I don't understand the entire front-end/back-end system to know how significant that change would be. Is this issue a non-starter (#302)?

Thanks.

@Carreau
Copy link
Member

Carreau commented Mar 29, 2018

cc @SylvainCorlay you know quite a bit more about widgets than I, do you have any hindsight ?
There are some plan to make the ipykernel more aware of async code., that may help but it wont' happen soon.

@SylvainCorlay
Copy link
Member

In general, people have been trying to do the opposite: prevent the notebook from blocking, for which we offer multiple scenarios.

I don't think that there is a simple method besides changing the execution model of the kernel, or capturing execution requests as explained above.

@kafonek
Copy link
Author

kafonek commented Aug 30, 2018

https://github.com/kafonek/ipython_blocking is out on pypi now as an alpha solution to this issue. I'm sure there's improvements and tweaks that can be made, so I'd appreciate any feedback.

@SylvainCorlay @maartenbreddels @jasongrout @minrk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants