jupyter / nbclassic

Jupyter Notebook as a Jupyter Server extension
https://nbclassic.readthedocs.io/en/latest
BSD 3-Clause "New" or "Revised" License
69 stars 60 forks source link

Notebook not reconnecting to cell output in progress on refresh #213

Open c0d3rman opened 1 year ago

c0d3rman commented 1 year ago

I've been trying to figure out the right place to post this issue, apologies if this is not it. A common problem with Jupyter notebooks is that if you have a long-running cell producing continuous output and you disconnect from the kernel temporarily (e.g. due to a refresh or putting your computer to sleep), the cell stops showing output. The code is still running, and output is still arriving (you can see the messages in the websocket in the browser developer tools), but the cell itself shows only the partial output from before the disconnect and the brackets next to the cell are empty as if it had not been run at all. Given that the output is making it to the browser, I assume this is some sort of issue with updating the output area. I've poked around a little and can't quite understand the architecture yet, but I figured y'all know it best and might know how to fix this. An example notebook cell for replicating this:

import time
i = 0
while True:
    time.sleep(1)
    i += 1
    print(i)

Run the cell, let it run for a bit, then refresh. Output stops showing, but you can see in dev tools that the messages are still coming through. Thanks for your help.

echarles commented 1 year ago

Thx for opening this @c0d3rman. This is a very interesting requirement I have been playing with yesterday as having to deeal with a long running cell execution - e.g. JupyterLab does not handle the reconnection to cell outputs, while solutions like Google Collab take that into account. I have not searched the various Jupyter repos for prior discussion so I can not say for now if that question has ever been tackled.

I will add a topic at today notebook community meeting.

cc/ @RRosio @ericsnekbytes @blink1073 @Zsailer @kevin-bates @seibert

kevin-bates commented 1 year ago

This is a long-standing issue and one that will hopefully be resolved by the real-time collaboration (RTC) efforts. There have been numerous issues opened for this, in multiple repositories, but the one issue often referenced (and appears to still be somewhat active in that it contains RTC-related comments) is https://github.com/jupyter/notebook/issues/641.