-
-
Notifications
You must be signed in to change notification settings - Fork 695
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
Graceful shutdown #83
Comments
NiceGUI is using uvicorn as a server which has still problems with graceful shutdowns (see encode/uvicorn#1103 for example). We need to think about this a bit. My not so graceful suggestion would be to start NiceGUI without from nicegui import ui
import sys
def apply():
print('Starting main system in seperate process')
# subprocess.Popen(['python3', 'my_main_system.py'])
sys.exit(0)
ui.label('Configuration')
ui.label('... your config UI here ...')
ui.button('Apply', on_click=apply)
ui.run(reload=False) |
Yes, it would be great to have something like from nicegui import ui
ui.label('Your configurtion UI...')
def quit():
... # How?
ui.button('Quit', on_click=quit)
ui.run(reload=False)
print('Do something else...') It's a pity that Monkey-patching |
The solution
I've pushed the code to branch #83-Process. |
I've got a first idea working on #83-ui.shutdown. ui.button('Quit', on_click=ui.shutdown) But there is still work to be done. For example auto-reloading is still broken. |
I tried to add more code from Now the app starts with Another issue: When the socket connection is lost due to the server being shut down, the JustPy frontend asks for confirmation to reload the page. This makes no sense and should be avoided. |
Nice! After moving ui.shutdown into the lifecycle module the reload-confirmation dialog is gone. |
The |
Correction: app.shutdown |
Is there any way of gracefully shutting down the server after use? I am using it to have a configuration page for a larger project and once the configuration is completed the main part of the project takes over and no more configuration is needed. I would like to kill everything UI related at that point.
The text was updated successfully, but these errors were encountered: