-
-
Notifications
You must be signed in to change notification settings - Fork 538
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
Async callback in Element.on() can lead to IndexError in slot stack #285
Comments
Hi @falkoschindler, import asyncio
from nicegui import ui, Client
from nicegui.events import ClickEventArguments, handle_event
@ui.page('/')
async def main_page(client: Client):
async def handle_click():
await asyncio.sleep(0.1)
ui.notify('clicked')
ui.button('Works', on_click=handle_click)
button = ui.button("Works with effort")
button.on("click", lambda _: handle_event(handle_click, ClickEventArguments(sender=button, client=button.client)))
ui.button('Fails').on('click', lambda _: handle_click())
ui.run(show=False) |
Thanks for sharing, @SebastienDorgan! That's a great workaround. And that's basically what needs to be done to fix |
I created PR #305 which should solve this issue. |
I've just merged the code. |
Discussed in #280
Here is a minimal reproduction. The first button works as expected, the second one doesn't.
Element.on()
Element
available asui.element
The text was updated successfully, but these errors were encountered: