Provide request timeout for blocking API (#764)

This commit is contained in:
Konrad Gołuchowski
2020-01-07 21:24:23 +01:00
committed by Sean McArthur
parent b159963f6c
commit 22fe6566ff
3 changed files with 57 additions and 2 deletions

View File

@@ -670,6 +670,8 @@ impl ClientHandle {
let (tx, rx) = oneshot::channel();
let (req, body) = req.into_async();
let url = req.url().clone();
let timeout = req.timeout().copied().or(self.timeout.0);
self.inner
.tx
.as_ref()
@@ -683,12 +685,12 @@ impl ClientHandle {
body.send().await?;
rx.await.map_err(|_canceled| event_loop_panicked())
};
wait::timeout(f, self.timeout.0)
wait::timeout(f, timeout)
} else {
let f = async move {
rx.await.map_err(|_canceled| event_loop_panicked())
};
wait::timeout(f, self.timeout.0)
wait::timeout(f, timeout)
};
match result {