Running ui.run from an asynchronous function with reload=False causes an error #5389
MaidScientistIzutsumiMarin
started this conversation in
Ideas / Feature Requests
Replies: 2 comments
-
|
Might be possible with some modifications/additons to ui.run. We must somehow configure a server start without creating a new event loop. How would that look with FastAPI? |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
It would look like this. app = FastAPI()
config = uvicorn.Config(app, host="127.0.0.1", port=8000, loop="asyncio")
server = uvicorn.Server(config)
await server.serve()How about providing an |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
First Check
Example Code
Description
Start the app. It crashes immediately with:
RuntimeError: asyncio.run() cannot be called from a running event loopThis crash only happens when
reload=Falseis present in the above example.NiceGUI Version
3.2.0
Python Version
3.14.0
Browser
Other
Operating System
Windows
Additional Context
Having
reload=Falsein required in situations like if the program is being packaged for distribution or called from an entry point. Is there an alternative pattern that should be used to handle asynchronous resources liked this?Beta Was this translation helpful? Give feedback.
All reactions