-
We have a wrapper for tokio::spawn, then most of our code uses this wrapper instead of vanilla tokio::spawn, this makes the console's spawn_location always same. Is there someway to attach extra info to the task's key values? |
Beta Was this translation helpful? Give feedback.
Answered by
shuoli84
Sep 7, 2021
Replies: 1 comment
-
Update: #[track_caller]
pub fn try_spawn<T>(
label: String,
task: T,
) -> Result<tokio::task::JoinHandle<Option<T::Output>>, StopGuardError>
where
T: Future + Send + 'static,
T::Output: Send + 'static,
{
match stop_receiver() {
Some(stop_receiver) => Ok(tokio::spawn(start(label, stop_receiver, task))),
None => Err(StopGuardError),
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
hawkw
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Update:
#[track_caller] saved my day. Just learned the macro from tokio spawn and it can be chained, so I just add it to our wrapper and the spawn location works. E.g