This repository has been archived by the owner on Jul 18, 2024. It is now read-only.
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
You can continue the conversation there. Go to discussion →
I'm trying to run fastapi app with custom lifespan-aware middleware.
It works fine under
uvicorn
, but fails oddly undermangum
.The error is:
(That's Py 3.10 error, the exception is a bit misleading: https://bugs.python.org/issue45996)
The cause is that my middleware accepts an instance of an
asynccontextmanager
, and it runs__aenter__
onlifespan.startup
and
__aexit__
onlifespan.shutdown
.In the FastAPI/starlette/uvicorn combo, there's a case (maybe even an assumption) that startup and shutdown are ran only once. After that the entire
app
is thrown away.However, it seems, as if
mangum
runslifespan.startup
multiple times.Perhaps that's how it deals with lambda being suspended?
The text was updated successfully, but these errors were encountered: