I've learned the hard way that this is not quite right:
tokio::run(response_is_ok);
Depending on what happens inside client, this can hang forever. This actually does happen with reqwest::async since Hyper tend to spawn long-living futures, presumably for keep-alive connections in its pool.
What I had to use to make it reliable is
letmutrt=Runtime::new().expect("Cannot create a runtime");rt.block_on(response_is_ok).expect("Failed");
As a nice side effect you get the outcome of the future as a Result, you don't have to force it to be Future<Item = (), Error = ()>.
Hi Bastian,
I've learned the hard way that this is not quite right:
Depending on what happens inside client, this can hang forever. This actually does happen with
reqwest::async
since Hyper tend to spawn long-living futures, presumably for keep-alive connections in its pool.What I had to use to make it reliable is
As a nice side effect you get the outcome of the future as a
Result
, you don't have to force it to beFuture<Item = (), Error = ()>
.Thats super helpful, thank you so much Dmitry!