doc(tokio): Set keep_alive to false on hyper clients.

This prevents hanging event loops.
This commit is contained in:
Lewin Bormann
2019-06-13 18:41:09 +02:00
parent f034b8bea4
commit 0eb1268567
4 changed files with 16 additions and 9 deletions

View File

@@ -13,7 +13,9 @@ fn main() {
let creds =
yup_oauth2::service_account_key_from_file(path::Path::new("serviceaccount.json")).unwrap();
let https = HttpsConnector::new(1).expect("tls");
let client = Client::builder().build::<_, hyper::Body>(https);
let client = Client::builder()
.keep_alive(false)
.build::<_, hyper::Body>(https);
let mut sa = yup_oauth2::ServiceAccountAccess::new(creds, client);
@@ -29,7 +31,6 @@ fn main() {
println!("cached token is {:?} and should be identical", tok);
Ok(())
});
let all = fut.join(fut2);
let mut rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(all).unwrap();
let all = fut.join(fut2).then(|_| Ok(()));
tokio::run(all)
}