Open simonwarchol opened 1 year ago
New to rust, so appreciate the help.
I'm trying to call block on an async function within rust and it's throwing errors, was wondering if this is possible.
Using futures = {version="0.3.28", features=["executor"]}
futures = {version="0.3.28", features=["executor"]}
use futures::executor::block_on; pub fn test() -> Vec<f32> { block_on(test_diff()) } pub async fn test_diff() -> Vec<f32> { let result = async_func.await; result }
but getting a RuntimeError: unreachable error.
Any guidance would be greatly appreciated.
Generally, in WASM, you never want to actively "block". It's all single threaded, so "blocking" would make everything unresponsive. This is why mutexes and other thread blocking primitives don't work on WASM.
Instead, you want to spawn your future.
spawn
New to rust, so appreciate the help.
I'm trying to call block on an async function within rust and it's throwing errors, was wondering if this is possible.
Using
futures = {version="0.3.28", features=["executor"]}
but getting a RuntimeError: unreachable error.
Any guidance would be greatly appreciated.