Skip to content

How to spawn a task with task_local? #4317

Answered by Darksonn
lz1998 asked this question in Q&A
Discussion options

You must be logged in to vote

You would need to set the task local in the child task as well. Alternatively, you can use combinators such as tokio::join!, FuturesUnordered or StreamExt::buffer_unordered which don't actually spawn independent tasks, so task locals remain active inside them.

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@lz1998
Comment options

@Darksonn
Comment options

@lz1998
Comment options

@Darksonn
Comment options

Answer selected by lz1998
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