You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
%guiasyncioimportasyncioimportipywidgetsaswidgetsbuttons=widgets.Output()
lines=widgets.Output()
display(buttons, lines)
asyncdeffunc():
foriinrange(5):
# Render new buttonbuttons.clear_output()
withbuttons:
display(widgets.Button(description=str(i)))
# Append new linewithlines:
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.
Context
ipywidgets version 8.1.2
Operating System and version: Arch Linux
Browser and version: Mozilla Firefox 125.0b6
The text was updated successfully, but these errors were encountered:
and3rson
changed the title
Displaying new widgets from within async function does not work as intended
Rendering output from within async function does not work as intended
Apr 9, 2024
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:
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.Context
The text was updated successfully, but these errors were encountered: