Skip to content
Discussion options

You must be logged in to vote

Ah, you seem to have forgotten to await coordinate inside the task that you spawned!

The task you spawned does nothing but return the future, as you never await it within the block. In other words, the future that you spawned just returns a future. This is why you await twice when you await the handle. You are first awaiting the spawned task, and then awaiting the future that you had meant to run within it, but didn't.

If you await coordinate method within the async block, that should fix the issue. You could also simply get rid of the async block entirely, and simply tokio::task::spawn(Race::coordinate(racer1, r1)), which would be a bit more succinct.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by moh-eulith
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