-
-
Notifications
You must be signed in to change notification settings - Fork 627
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
When native is True and reload is True, port is ignored and app_shutdown never fires #2107
Comments
Currently, port is not used in native mode as #1457 stated. I have made a pull request to change this. However, I don't know why app_shutdown never fires. |
Thanks @retsyo. On Mac M1 the shutdown works as expected. Are you running on Windows @PawelRoman? Does the shutdown work if you disable reload? What does happen when you use the buttons ui.button('destroy window', on_click=lambda: app.native.main_window.destroy())
ui.button('nicegui shutdown', on_click=lambda: app.shutdown()) |
On my windows 10 64 bits, both buttons close the window and python ui.button('destroy window', on_click=lambda: app.native.main_window.destroy())
ui.button('nicegui shutdown', on_click=lambda: app.shutdown())
ui.run(reload=False, native=True) and PawelRoman's code runs def app_shutdown():
print('app shutdown')
app.on_shutdown(app_shutdown)
ui.run(reload=False, native=True) so does |
I fear this must be debugged on a Windows system. On Mac the demo you provided prints the shutdown message. Any help would be appreciated. |
As I wrote in the original post, I work on Ubuntu 20 (Linux Mint). The |
@PawelRoman thanks for the port fix :) saw that it got merged Tried your examples on a Win 10 machine & python 3.11, came to the same conclusion that the app startup does get printed and the app shutdown doesn't fire with reload=True unless I Ctrl+C the app, when I set reload=False it fires without having to use Ctrl+C. So that means on both Linux Mint & Win 10 the shutdown event doesn't seem to trigger with reload set to True. Perhaps the reload/directory&file watcher functionality makes uvicorn spawn a watcher thread and won't let go of it unless Ctrl+C'd? |
Uvicorn just fixed encode/uvicorn#2289 and released version 0.30.0. |
Description
Platform:
Linux Mint 20.03 (ubuntu)
NiceGUI 1.4.3
Steps to replicate:
Save the code below as main.py and run
python main.py
Expected: Window app opens up, server starts on port 8502, app startup printed out.
Actual: Window app opens up, app startup printed out, but server starts on port 8000 (note: I double checked that 8502 is NOT taken by some other process)
Then close the window by clicking "X"
Expected: app shutdown printed out
Actual: nothing is printed out, the app_shutdown function is never called
The text was updated successfully, but these errors were encountered: