8000 Setting context variables in the lifespan handler? · encode starlette · Discussion #2078 · GitHub
[go: up one dir, main page]

Skip to content

Setting context variables in the lifespan handler? #2078

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

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: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@jonathanslenders
Comment options

Answer selected by Kludex
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
0