Gracefully close UI on shutdown #297
Replies: 3 comments 3 replies
-
The most important is to stop the browser from reconnecting (which I did not find how). |
Beta Was this translation helpful? Give feedback.
-
Maybe we could send some last UI update to the server before actually shutting down. I think a context aware shutdown could provide this quite nicely: with app.shutdown():
with ui.dialog(), ui.card():
ui.label('Bye').classes('text-5xl') On entering the context the shutdown command would execute the UI and on leaving it would execute a yet to be implemented "stopReconnecting" javascript function. After that the server can be stopped. |
Beta Was this translation helpful? Give feedback.
-
Is it really a good idea to implement this with a context? Maybe it's more like a page: @app.after_shutdown()
def bye_bye():
with ui.dialog(), ui.card():
ui.label('Bye').classes('text-5xl') |
Beta Was this translation helpful? Give feedback.
-
As @smojef mentioned in discussion #290 it would be nice to be able to gracefully shutdown NiceGUI. There is already an
app.shutdown()
to shutdown the server (requiresui.run(..., reload=False)
). But the browser tab will show a warning about a lost connection and will try to reconnect. We should somehow tell the client about the shutdown. So the browser can either simply stop reconnecting, or show some message, or close the tab (probably not possible).Beta Was this translation helpful? Give feedback.
All reactions