You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I start the application with uvicorn main.app:app:
INFO: Started server process [340374]
INFO: Waiting for application startup.
on_startup()
INFO: Application startup complete.
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
^CINFO: Shutting down
INFO: Waiting for application shutdown.
INFO: Application shutdown complete.
INFO: Finished server process [340374]
It seems like the on_shutdown method is not being called.
After some digging in the ASGIApp source code I found that self.lifespan is only awaited once (but there are two events to be received).
INFO: Started server process [340470]
INFO: Waiting for application startup.
on_startup()
INFO: Application startup complete.
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
^CINFO: Shutting down
INFO: Waiting for application shutdown.
on_shutdown()
INFO: Application shutdown complete.
INFO: Finished server process [340470]
I don't know if awaiting ASGIApp.lifespan twice is a solution that conforms the ASGI standard but so far it seems to work on all ASGI servers I've tried.
I've tried shutting down uvicorn with kill to see if it'd make a difference compared to Ctrl-C, but it didn't seem to matter.
My versions are: python 3.8.5, python-socketio==4.6.0, python-engineio==3.13.2
The text was updated successfully, but these errors were encountered:
I have the following ASGI application:
When I start the application with
uvicorn main.app:app
:It seems like the on_shutdown method is not being called.
After some digging in the ASGIApp source code I found that
self.lifespan
is only awaited once (but there are two events to be received).I updated my code as such:
Now the result is this:
I don't know if awaiting
ASGIApp.lifespan
twice is a solution that conforms the ASGI standard but so far it seems to work on all ASGI servers I've tried.I've tried shutting down uvicorn with
kill
to see if it'd make a difference compared to Ctrl-C, but it didn't seem to matter.My versions are: python 3.8.5, python-socketio==4.6.0, python-engineio==3.13.2
The text was updated successfully, but these errors were encountered: