Skip to content

Spawned write to file never finishes when running single threaded #973

Open
@Jonathas-Conceicao

Description

@Jonathas-Conceicao

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"] }

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions