async-std
async-std copied to clipboard
Spawned write to file never finishes when running single threaded
I've recently had a issue when running a application on a single core machine (an old Raspberry Pi) where a Future would never finish. I have managed to reproduce the problem with the following small example on x64 as well:
use async_std::{fs, io::prelude::WriteExt};
#[async_std::main]
async fn main() {
let handle = async_std::task::spawn(async {
let mut handle = fs::OpenOptions::new()
.create(true)
.write(true)
.open("/tmp/foo")
.await
.unwrap();
handle.write_all(&[0; 313]).await.unwrap();
println!("Future finished!");
});
handle.await;
}
If this is executed while setting ASYNC_STD_THREAD_COUNT=1 the application doesn't finish. If I instead write to something else (like a Vec) the application finishes as expected. Additionally if I use async_std::task::spawn_local instead of spawnor just await the future in the main thread, the application also finishes as expected.
Here's the toml file:
[package]
name = "testing_async_std"
version = "0.1.0"
edition = "2018"
[dependencies]
async-std = { version = "=1.9.0", features = ["attributes"] }
I did some testing changing version numbers of async-std and I've found that using the version "=1.6.2" worked as expected, while version "=1.6.3" and newer would reproduce this issue.
The "1.6.3" changed the executor. This might explain the behavior change.
@dignifiedquire please take a look at this; this is a regression.