-
Notifications
You must be signed in to change notification settings - Fork 950
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
Output widget context manager prints to wrong cell (if used in a Thread) #2358
Comments
Can you read https://ipywidgets.readthedocs.io/en/stable/examples/Output%20Widget.html#Interacting-with-output-widgets-from-background-threads carefully, which talks about using an output widget from a thread, and then post your thoughts about it? |
This ties into the discussion with @andymcarter on gitter. |
@jasongrout That exactly describes what I saw and disliked. I also thought about the solution to pass around widgets that is presented there but didn't like it because it can't be used to create non intrusive cell magic. It would be awesome if you guys found a way around jupyter's shortcomings somehow. I realize that at this point it's really not about actual widgets anymore but maybe you still feel like it's.a useful thing to have |
+1. Having some fix for this would be great. I'm basically trying to start up a bunch of jobs that print to separate Output widgets inside tabs, but I don't have the ability to go into the job code I'm running and change the output statements to use Do you see it being possible to rework the Output widget so that they can capture outputs from different threads concurrently and place them in their own widget? I see that output widgets get streamed their outputs using a |
That's the key problem in the current IPython kernel - the parent header (which is how things are routed) is a global shared across all threads. |
Gotcha. Are there plans to improve that situation? Or is it something that's too difficult to address without completely uprooting things |
I don't know of anyone working on this in IPython itself (though that repo would be the place to ask). @SylvainCorlay and some others from quantstack are experimenting with a new python kernel based on the C++ backend xeus that experiments with other concurrency models. |
It wouldn't be such a bad idea to refactor the output widget. We could have the same logic in the frontend and backend (so that the Output widget behaves the same without a front-end connected). And if we send the outputs using a custom msg, we could send the msg_id with it. |
Hmmm. I haven't really looked into this or tested it, but from a cursory glance, I wonder if something like this could be a bandaid? It would have to be extended for multiprocessing as well and I'm not quite sure how to make it work with https://stackoverflow.com/a/43667367 Basically, it adds a proxy around |
I don't know if this is the same issue, but the output also shows up at the wrong place when using |
This was a separate problem with nbconvert not supporting output widgets. |
There was no slider or toggle widget in the original description, it was about output widgets capturing standard output in threads. Is that the issue you are commenting about? If not, can you please open a new issue with steps to reproduce what you are seeing and a full description of the problem and what you expect? |
For reference: The proposed workaround does not work with |
Is it possible to have a similar thing in a multiprocess environment? |
@jasongrout was there ever a discussion about modifying kernel-frontend protocol to include cell ID in messaging (and routing) to ensure that the output goes to the correct cell? |
ipython/ipykernel#1186 proposes a solution on ipykernel side using |
If I wrap this code from
source/docs/examples/Output Widget.ipynb
,in a Thread,
then the output ends up in a wrong cell as soon as I execute another cell.
I would consider this a bug, as I cannot imagine anyone wanting the Output widget to change cells. To convince you of the awesomeness of updating the Output widget in the cell where it was started, imagine how easy it would be to make a simple
out of this (indeed, that's what I did, and it works beautifully except for the problem above. In my application, I need a simple job monitor, but I am sure there would be dozens of different uses for this)
The text was updated successfully, but these errors were encountered: