I'm playing with Warp and Rust and I have my webserver running so that it will accept REST API calls, however once I get the call I need to call a seperate webserver, which is a blocking operations, and get this error:
thread 'tokio-runtime-worker' panicked at 'Cannot drop a runtime in a context where blocking is not allowed. This happens when a runtime is dropped from within an asynchronous context.', C:\Users\Owner.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-0.2.22\src\runtime\blocking\shutdown.rs:49:21
I could make that call asynchronously but then I don't see a way to return the results from the warp web server.
Code found here, it's a challenge problem for an interview:
The error is being thrown after I added the following code to the 'list_users' function in handlers.rs line 19:
let mut res = reqwest::blocking::get("https://jsonplaceholder.typicode.com/users").unwrap();
let mut body = String::new();
res.read_to_string(&mut body);
//temporarily printing to string
println!("Body:\n{}",body);
I suppose I could work around this, something like this returns a token, then makes polling calls using that token to see if it's result is done. Seems like there should be a way to do this without using something like that such as telling warp that the API will block.
Thanks!