-
-
Notifications
You must be signed in to change notification settings - Fork 917
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 on_shutdown function raises error, starlette doesn't catch it and uvicorn thinks that lifespan is not supported #1138
Comments
Note also that shutdown.failed is not implemented in uvicorn , PR exists though Not sure that would help anyway since starlette doesn't make use of it. |
A quick update: actually is encode/uvicorn#755. Which is already merged. But as @euri10 said, it doesn't help as |
A workaround that I use in the mean time is just adding the middleware to correctly deal with lifespan events yourself.
People with a better understanding of ASGI then me could probably make this more elegant. But using uvicorn where encode/uvicorn#755 is merged I now get using the above:
|
Checklist
master
.Describe the bug
When one of the on_shutdown functions raises an error
To reproduce
(Doesn't matter if the function is async or not)
uvicorn app:app --log-level trace
Expected behavior
The exception is caught, reported, and Starlette shuts down properly
Actual behavior
Logs:
Note that the TRACE messages are hidden, and all that is printed is "ASGI 'lifespan' protocol appears unsupported."
Debugging material
When I run uvicorn with
--lifespan on
, these logs appear:Environment
Additional context
Somebody likely ran into this here: https://stackoverflow.com/q/64512286/7292139
The text was updated successfully, but these errors were encountered: