ASGI Lifespan errored in Litestar #356
-
I am migrating my Litestar app from Uvicorn to Granian but I am getting, [WARNING] ASGI Lifespan errored, continuing without Lifespan support (to avoid Lifespan completely use "asginl" interface) Seeing #297, it seems this warning is issued if the framework doesn't support Lifespans, but I am certain that Litestar does. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I should probably review the logging for lifespan, as if the application won't return a lifespan error but just throw an exception, then Granian consider it as unsupported and avoid to log the actual exception – several people complained by log pollution in the past. There's definitely something going on in the litestar app during lifespan startup, but In order to retrieve the error, you should copy the ASGI spawn method from here https://github.com/emmett-framework/granian/blob/master/granian/server.py#L216-L275, edit the line if lifespan_handler.interrupt: and change it to if lifespan_handler.exc: So you can pass it to the Granian(...).serve(spawn_target=your_method) I know this is quite ugly and very far from being ideal, but at the time being is the only option to log that exception. |
Beta Was this translation helpful? Give feedback.
I should probably review the logging for lifespan, as if the application won't return a lifespan error but just throw an exception, then Granian consider it as unsupported and avoid to log the actual exception – several people complained by log pollution in the past.
There's definitely something going on in the litestar app during lifespan startup, but In order to retrieve the error, you should copy the ASGI spawn method from here https://github.com/emmett-framework/granian/blob/master/granian/server.py#L216-L275, edit the line
and change it to
So you can pass it to the
Granian.serve
method as follows: