async-rs / async-rs/async-std

Cannot call task::block_on inside task::spawn

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

Description

As title.

This is an issue opening from what we found in https://github.com/rmanoka/async-scoped/issues/2

Below is the code snippet that reproduce the problem, by the author of project there:
```
#[test]
fn test_recursive_block() {
task::block_on(async {
task::spawn(async {
task::block_on(async {
eprintln!("Hello block!");
})
});
})
}
```

for myself, I would like to see if there is any suggestion of spawning a scoped task so i can reaccess the variable without giving up ownership.

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.