GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — does async callback supported? · Issue #41 · webui-dev/python-webui

does async callback supported? #41

New issue
Copy link
New issue
Copy link
Open
Open
does async callback supported?#41
Copy link

Description

@congzhangzh
congzhangzh
opened on Sep 26, 2025
Issue body actions

like title!

Activity

  1. AlbertShown commented on Sep 26, 2025

    @AlbertShown
    AlbertShown
    on Sep 26, 2025
    Member
    More actions

    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#L116
    
    set_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 UI
    
    def myCallbackExample(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.
    Reacted by Cong Zhang
  2. congzhangzh commented on Sep 26, 2025

    @congzhangzh
    congzhangzh
    on Sep 26, 2025
    Author
    More actions

    Tks, Btw how you guys stop asyncio event loop from blocking, as main thread is waiting?

    webui.wait()

    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

  3. congzhangzh commented on Sep 26, 2025

    @congzhangzh
    congzhangzh
    on Sep 26, 2025
    Author
    More actions

    use multi thread?

  4. AlbertShown commented on Sep 29, 2025

    @AlbertShown
    AlbertShown
    on Sep 29, 2025
    Member
    More actions

    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

    Reacted by Cong Zhang
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.