Open oubeichen opened 1 month ago
Hi @oubeichen - does mounting gradio in get_app
instead of in the context manager fix the issue?
Hi @oubeichen - does mounting gradio in
get_app
instead of in the context manager fix the issue?
Mounting a fixed interface of Gradio in get_app
works. However, get_app
is a synchronous method, but I need to use asynchronous methods in mount_gradio
to read from the database/settings and dynamically change the Gradio interface.
Describe the bug
My project is developed using FastAPI. I need to load some asynchronous operations (such as reading configuration and database) after FastAPI starts, specifically during the startup event of the lifespan. (Since the codes are synchronous when uvicorn starts the app, it’s inconvenient to use asyncio.)
After these operations, I mount Gradio. I managed to open the Gradio page, but found that the interactions get no response.
Later, I found these: https://github.com/gradio-app/gradio/issues/6718 https://github.com/gradio-app/gradio/pull/6759
However, these only address the issues when FastAPI uses lifespan, not the problems arising when using mount_gradio_app while already in lifespan.
Does anyone have any good suggestions? Thanks.
Have you searched existing issues? 🔎
Reproduction
test.py
Screenshot
Logs
No response
System Info
Severity
Blocking usage of gradio