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
WebUI supports it, it's implemented by default in some wrappers like Deno-WebUI because everything is async, but in Python-WebUI I think it should be done manually.
To make your WebUI project support async try this:
1 - initialize WebUI with async enabled
# in your main start, initialize WebUI with async enabled# Config.asynchronous_response = number 5# More info: # https://github.com/webui-dev/python-webui/blob/c4b55892baa9367dd7cd4005ab30542e81f954b4/PyPI/Package/src/webui/webui.py#L116set_config(Config.asynchronous_response, True)
# Now, WebUI events will bypass the callback instant return, and wait forever for the async response trough any `e.return_xxx()`
2 - Set your event async response
# In your events call, make sure to call any `e.return_xxx()` to set your async response to the UIdefmyCallbackExample(e : webui.Event):
# do your async operations...# Python may return right away a void response to C (WebUI), but WebUI will ignore it and wait for any `e.return_xxx()`e.return_int(123) # Now WebUI will pass the response to UI.
Activity
AlbertShown commentedon Sep 26, 2025
WebUI supports it, it's implemented by default in some wrappers like Deno-WebUI because everything is async, but in Python-WebUI I think it should be done manually.
To make your WebUI project support async try this:
1 - initialize WebUI with async enabled
2 - Set your event async response
congzhangzh commentedon Sep 26, 2025
Tks, Btw how you guys stop asyncio event loop from blocking, as main thread is waiting?
I am the author of https://github.com/congzhangzh/webview_python , to make wait work, I even monkey patch python asyncio, like:
https://github.com/congzhangzh/webview_python/tree/main/examples/async_with_asyncio_guest_run
congzhangzh commentedon Sep 26, 2025
use multi thread?
AlbertShown commentedon Sep 29, 2025
this project structure is different from your project structure because this one calls a C external library, while yours is directly using webview.
However, code is here:
https://github.com/webui-dev/python-webui/blob/c4b55892baa9367dd7cd4005ab30542e81f954b4/PyPI/Package/src/webui/webui.py#L1544C5-L1544C22