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
Well, seems like it's not so easy. We can't get FastAPI.lifespan_context inside our router.lifespan method. We should figure it out before implement this feature
Well, we missed ASGI State feature – https://www.starlette.io/lifespan/
The following code should works without errors
But, it couldn't be implemented in a regular way. Originally, ASGI server stores yielded values and injects it in each HTTP request – https://asgi.readthedocs.io/en/latest/specs/lifespan.html#lifespan-state
But, there is ni HTTP request and ASGI server on
router.subscriber
call, so we should inject this state manually.We should pass this
maybe_state
– https://github.com/airtai/faststream/blob/main/faststream/broker/fastapi/router.py#L315To
request
object – somewhere here https://github.com/airtai/faststream/blob/main/faststream/broker/fastapi/route.py#L210The text was updated successfully, but these errors were encountered: