async-rs / async-rs/async-std

Spawned write to file never finishes when running single threaded

Open
#973 3 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Rust
Stars
4.1k
Forks
339
PR merge metrics
No merged PRs in 30d

Description

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:

```Rust
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 `spawn`or just `await` the future in the main thread, the application also finishes as expected.

Here's the toml file:
```toml
[package]
name = "testing_async_std"
version = "0.1.0"
edition = "2018"

[dependencies]
async-std = { version = "=1.9.0", features = ["attributes"] }
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.