-
Hi all, I spent hours debugging a strange issue that occurs when using I have the following simple code, which is part of a full working example: async fn main() {
let (mut reader, _writer) = TcpStream::connect((addr, port))
.await
.unwrap()
.into_split();
tokio::spawn(async move {
loop {
eprintln!("{}", reader.read_u8().await.unwrap());
}
});
} In my head, I expect This is not what happens:
From what I can tell, To me, this is totally unexpected since the task should own Am I misunderstanding something? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
What's happening is that you return from |
Beta Was this translation helpful? Give feedback.
-
Found the issue: I wasn't holding on to the |
Beta Was this translation helpful? Give feedback.
No, not unless the method is annotated with
#[tokio::main]
.