-
Notifications
You must be signed in to change notification settings - Fork 965
Open
Description
Description
Widget updates from the async consumer task appear to be buffered until another cell finishes.
This happens in JupyterLab, but not in JupyterLite (Pyodide/Xeus), where the same pattern works as expected.
Minimal notebook repro
import asyncio
import ipywidgets as W
from IPython.display import display
q = asyncio.Queue()
out = W.Output()
button = W.Button(description="Click me")
def on_click(_):
q.put_nowait("click")
button.on_click(on_click)
async def consumer():
counter = 0
while True:
item = await q.get()
counter += 1
with out:
out.clear_output(wait=True)
print(f"GOT click {counter}")
loop = asyncio.get_event_loop()
task = loop.create_task(consumer())
display(button, out)Observed behavior
- Run the cell above.
- Click the "Click me" button several times.
- Notice that no "GOT click N" output appears in the Output widget.
- Execute a next cell with any valid Python
- Notice that only then does the previous cell's output update and show:
GOT click 1
So widget updates from the async consumer task appear to be buffered until another cell finishes.
Expected behavior
Each button click should immediately cause the consumer task to update the Output widget, and the new content should be visible right away in JupyterLab, just like it is in JupyterLite (same pattern works there).
Context
- Python: 3.11.9
- ipywidgets: 8.1.8
- jupyterlab_widgets: 3.0.16
- JupyterLab: 4.5.1
- ipykernel: 7.1.0
- Labextensions:
- jupyterlab_pygments v0.3.0 enabled OK (python, jupyterlab_pygments)
- jupyter-leaflet v0.20.0 enabled OK
- jupyterlab-filesystem-access v0.7.0 enabled OK (python, jupyterlab-filesystem-access)
- @jupyter-widgets/jupyterlab-manager v5.0.15 enabled OK (python, jupyterlab_widgets)
- @jupyterlite/pyodide-kernel-extension v0.7.0 enabled OK (python, jupyterlite_pyodide_kernel)
- @jupyterlite/xeus-extension v4.3.7 enabled OK (python, jupyterlite_xeus)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels