Skip to content

future that is spawened with spawn_with_handle is not executed if handle is dropped #1436

Open
@SrTobi

Description

@SrTobi

Not sure if this is a bug or only not mentioned in the documentation. The following code,

let mut pool = LocalPool::new();
let mut spawner = pool.spawner();

let f = async {
    println!("first");
    3
};

let handle = spawner.spawn_with_handle(f).unwrap();

//drop(handle);

println!("Start run");
pool.run();

as expected, outputs:

Start run
first

If the line drop(handle) is uncommented, f is not executed anymore and only he following output is produced:

Start run

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions