You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Version
List the versions of all tokio crates you are using. The easiest way to get
this information is using cargo tree subcommand:
cargo tree | grep tokio
tokio v1.40.0
Platform
The output of uname -a (UNIX), or version and 32 or 64-bit (Windows)
Windows
Description
Enter your issue details here.
One way to structure the description:
[short summary of the bug]
a task in one spawn will prevent the execution of a task in another spawn
I tried this code:
[code sample that causes the bug]
#[tokio::main]
async fn main() {
tokio::spawn(async move {
let handle = std::thread::current();
println!("Execute thread::{:?}::{:?}", handle.id(), handle.name());
let mut i = 0;
loop {
if i < 2 {
i = i + 1;
println!("spawn {i}");
tokio::spawn(async move {
demo(i).await;
});
} else {
// Only when this spawn is suspended will the output in the “fn demo” be executed
// tokio::task::yield_now().await;
}
}
}).await;
}
async fn demo(i: i32) {
let handle = std::thread::current();
println!("Execute thread::{}::{:?}::{:?}", i, handle.id(), handle.name());
}
I expected to see this happen: [explanation]
I thought println in the “fn demo” would execute correctly
Instead, this happened: [explanation]
But during execution, it was found that the 'fn demo' would be blocked
Execute thread::ThreadId(8)::Some("tokio-runtime-worker")
spawn 1
spawn 2
Execute thread::1::ThreadId(6)::Some("tokio-runtime-worker")
The text was updated successfully, but these errors were encountered:
Version
List the versions of all
tokio
crates you are using. The easiest way to getthis information is using
cargo tree
subcommand:cargo tree | grep tokio
tokio v1.40.0
Platform
The output of
uname -a
(UNIX), or version and 32 or 64-bit (Windows)Windows
Description
Enter your issue details here.
One way to structure the description:
[short summary of the bug]
a task in one spawn will prevent the execution of a task in another spawn
I tried this code:
[code sample that causes the bug]
I expected to see this happen: [explanation]
I thought println in the “fn demo” would execute correctly
like it:
Execute thread::ThreadId(6)::Some("tokio-runtime-worker")
spawn 1
spawn 2
Execute thread::2::ThreadId(6)::Some("tokio-runtime-worker")
Execute thread::1::ThreadId(11)::Some("tokio-runtime-worker")
Instead, this happened: [explanation]
But during execution, it was found that the 'fn demo' would be blocked
Execute thread::ThreadId(8)::Some("tokio-runtime-worker")
spawn 1
spawn 2
Execute thread::1::ThreadId(6)::Some("tokio-runtime-worker")
The text was updated successfully, but these errors were encountered: