-
Notifications
You must be signed in to change notification settings - Fork 286
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
Broadcast Comm shell messages on iopub #263
Comments
The idea is that when a client's model state is synced to the kernel, it is automatically rebroadcast out to all the other clients, so everyone gets the state update. |
See also jupyter-widgets/ipywidgets#1218 |
@vidartf as you mentioned in person over video, it cannot be avoided to send back the echo msg to the original front-end source. Why is that the case? |
Basically, when broadcasting on IOPub you cannot choose which clients to include/exclude. At least if I remember the discussion with @minrk correctly. |
Would be good to know that a design issue in 0mq (like almost 0 prob of being solvable), or something that could be solved on the python side. |
zmq subscriptions are a prefix-matching whitelist. Each SUB socket can subscribe to one or more topics. In Jupyter, we generally subscribe to What could theoretically work, given these constraints, would be for IOPub clients to opt-in to every topic they should receive, rather than everything:
This is not really feasible, for a variety of reasons:
But...The websocket connections between the server and browsers do not have this behavior, though. We do know about connected peers at this level, and could choose to avoid sending specific messages to specific endpoints based on their content and destination. This would be a significant deviation from the current notebook application spec, however, where the websocket messages map 1:1 onto the zmq messages. Doing so would make this not a part of the Jupyter protocol, but an optimization that the notebook server itself makes. |
We also already have a message with this behavior: execute_input is an IOPub message that all peers receive on every Since comm messages coming from the client are much less likely to be large than messages coming from the kernel, what @vidartf discussed with me today sounds good to me:
|
Ok, I like to idea of seeing it as an optimization. However, if this echoing is implemented, would it mean that every update from the frontend will be echoed back all the time (also in the case of just 1 front and 1 backend)? |
Yes, because it cannot be known at the kernel level how many frontends there are. |
There are some exceptions I can think of (e.g. a video stream synced back to the kernel). However, I think most of these scenarios are not very suitable for having many clients connected (several potentially competing data sources all trying to sync back to kernel). I'm guessing that is one scenario when you would want to disable echos.
Yes, and this could be optimized by turning of echos, but the overhead in keeping it should be reasonably low as long as the message are small (they will/should be discarded when received after message-level deserialization). |
A video stream would indeed be a really strong case on implementing this before having a way to not echo back to the originating frontend. |
Some thoughts:
|
Another problem with comm messages and multiple clients is that the spec says:
However, if you have two connections to the kernel, and one has the target name and the other doesn't, the one that doesn't have the target name will close the comm down in the kernel. Unfortunately, since comm messages aren't rebroadcast, this also means that the client that did open a comm will have no clue the comm was closed. |
The comm message protocol currently has implicit assumptions that only one kernel connection is handling comm messages. This option allows a kernel connection to opt out of handling comms. See jupyter/jupyter_client#263 This fixes the error where ipywidgets stops working if you open a notebook and a console to the same kernel, since the console automatically closes all comms since it does not have the comm target registered.
The comm message protocol currently has implicit assumptions that only one kernel connection is handling comm messages. This option allows a kernel connection to opt out of handling comms. See jupyter/jupyter_client#263 This fixes the error where ipywidgets stops working if you open a notebook and a console to the same kernel, since the console automatically closes all comms since it does not have the comm target registered.
According to the overarching messaging philosophy as laid out in the docs (emphasis added),
Following this logic, it would make sense if any incoming Comm messages on the shell socket were broadcast on the IOPub socket as well. @jasongrout pointed out that this might be useful for collaborative ipywidgets.
In chat, @minrk suggested a message type of something like
comm_echo
.The text was updated successfully, but these errors were encountered: