-
-
Notifications
You must be signed in to change notification settings - Fork 492
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
on_shutdown
callback not called on Windows 10
#1050
Comments
Thanks for reporting this issue, @chhinze! This is definitely unexpected. NiceGUI's lifecycle hooks like main.py: import uvicorn
from fastapi import FastAPI
app = FastAPI()
@app.on_event("startup")
async def startup_event():
print("Application startup")
@app.on_event("shutdown")
async def shutdown_event():
print("Application shutdown")
@app.get("/")
def read_root():
return {"Hello": "World"}
if __name__ == "__main__":
uvicorn.run('main:app', host="0.0.0.0", port=8000, reload=True) |
Thank you a lot for the quick response, @falkoschindler. I just tested your code. The problem persists also with the pure FastAPI example you provided. The output is:
On Linux, after the line
Thanks to your information that it is related to FastAPI I now found the open issues fastapi#6026 and fastapi#6391. A fix seems to be merged already back in April and is scheduled for uvicorn release 0.22.0. I guess the best option is to just wait for this release of FastAPI. Edit: Clarified that the fix is in uvocorn (not fastapi). |
Unfortunately not. Or none that we are aware of. We would really much like to execute some code before uvicorn reloads, but we have not found a way yet. |
Ok, we'll wait for encode/uvicorn#1584 to be released. |
It seems like this was already released in uvicorn 0.22.0 in April (https://github.com/encode/uvicorn/releases/tag/0.22.0)? However, uvicorn seems to be pinned to 0.20.0 in NiceGui. |
Yes, you are right. I was misguided by the milestone progress bar in the issue (encode/uvicorn#1584). Sorry for the confusion. |
@falkoschindler Can uvicorn be upgraded to 0.22.0? Or would there be blocking conflicts from changes in uvicorn 0.21.0 or 0.22.0? |
Ah, I assumed that development was on |
Yea, we normally do everything on |
Ok, uvicorn has been updated in commit 578de6a. It will be released with NiceGUI 1.3.0. Therefore I'll close this issue. |
Description
Hi all,
thanks for this awesome project.
Registering a callback with
app.on_shutdown
should lead to the callback to be called during hot reloading (described in https://nicegui.io/documentation#events). This worked on a machine with Ubuntu 23.04 as expected, but on Windows 10 it is not called.Minimal example to reproduce:
On Windows 10 the console Output is
In Ubuntu I see a line
Shutdown called
before the secondstartup called
, this is also what I would expect reading the documentation.Am I using it wrong?
Is this related to #604 i.e., the Ctrl handler is not set properly?
Best regards
Chris
The text was updated successfully, but these errors were encountered: