Skip to content

Setting context variables in the lifespan handler? #2078

Closed Answered by Kludex
jonathanslenders asked this question in Q&A

You must be logged in to vote

No, it's not possible to set a ContextVar on the lifespan, and to retrieve that value on the endpoint. It's not a limitation, it's just that by concept it doesn't make sense. The lifespan and the request-response cycle run in different tasks.

You'd use the new lifespan state for that.

Replies: 1 comment 1 reply

You must be logged in to vote
1 reply
@jonathanslenders

Answer selected by Kludex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants