When modifying outputs from async functions, modifying components attributes (and doing prints) works, but re-rendering outputs does not.
Reproduce
Consider code which attempts to re-render the output from within async function:
%gui asyncio
import asyncio
import ipywidgets as widgets
buttons = widgets.Output()
lines = widgets.Output()
display(buttons, lines)
async def func():
for i in range(5):
# Render new button
buttons.clear_output()
with buttons:
display(widgets.Button(description=str(i)))
# Append new line
with lines:
print(i)
_ = asyncio.ensure_future(func())
This re-renders the button 5 times and prints 5 messages as expected:
However, when adding a delay inside the function:
...
async def func():
for i in range(5):
+ await asyncio.sleep(0.1)
# Render new button
...
...the button output never updates and gets stuck at initially rendered instance. However, prints still work fine:
Expected behavior
with some_output: display(...) should always update UI, irregardless from where it was called from.
Description
When modifying outputs from async functions, modifying components attributes (and doing prints) works, but re-rendering outputs does not.
Reproduce
Consider code which attempts to re-render the output from within async function:
This re-renders the button 5 times and prints 5 messages as expected:![зображення](https://github.com/jupyter-widgets/ipywidgets/assets/190107/f63ab2c8-cc9f-4738-91a1-66bb705fde44)
However, when adding a delay inside the function:
...the button output never updates and gets stuck at initially rendered instance. However, prints still work fine:![зображення](https://github.com/jupyter-widgets/ipywidgets/assets/190107/a316a0be-6ddb-40ae-be6a-ac0e182b9645)
Expected behavior
with some_output: display(...)
should always update UI, irregardless from where it was called from.Context