mirror of https://github.com/astral-sh/uv
Add retries to tests that download from R2 (#15322)
Closes https://github.com/astral-sh/uv/issues/15318.
This commit is contained in:
parent
d8f3f03198
commit
0243f91c9b
|
|
@ -4994,6 +4994,7 @@ dependencies = [
|
||||||
"assert_cmd",
|
"assert_cmd",
|
||||||
"assert_fs",
|
"assert_fs",
|
||||||
"axoupdater",
|
"axoupdater",
|
||||||
|
"backon",
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"clap",
|
"clap",
|
||||||
|
|
|
||||||
|
|
@ -117,6 +117,7 @@ windows-result = { workspace = true }
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
assert_cmd = { workspace = true }
|
assert_cmd = { workspace = true }
|
||||||
assert_fs = { workspace = true }
|
assert_fs = { workspace = true }
|
||||||
|
backon = { workspace = true }
|
||||||
base64 = { workspace = true }
|
base64 = { workspace = true }
|
||||||
byteorder = { workspace = true }
|
byteorder = { workspace = true }
|
||||||
filetime = { workspace = true }
|
filetime = { workspace = true }
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,22 @@
|
||||||
#![cfg(feature = "r2")]
|
#![cfg(feature = "r2")]
|
||||||
|
|
||||||
|
use backon::{BackoffBuilder, Retryable};
|
||||||
use futures::TryStreamExt;
|
use futures::TryStreamExt;
|
||||||
use tokio_util::compat::FuturesAsyncReadCompatExt;
|
use tokio_util::compat::FuturesAsyncReadCompatExt;
|
||||||
|
|
||||||
async fn unzip(url: &str) -> anyhow::Result<(), uv_extract::Error> {
|
async fn unzip(url: &str) -> anyhow::Result<(), uv_extract::Error> {
|
||||||
let response = reqwest::get(url).await.unwrap();
|
let backoff = backon::ExponentialBuilder::default()
|
||||||
|
.with_min_delay(std::time::Duration::from_millis(500))
|
||||||
|
.with_max_times(5)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
let download = || async {
|
||||||
|
let response = reqwest::get(url).await?;
|
||||||
|
Ok::<_, reqwest::Error>(response)
|
||||||
|
};
|
||||||
|
|
||||||
|
let response = download.retry(backoff).await.unwrap();
|
||||||
|
|
||||||
let reader = response
|
let reader = response
|
||||||
.bytes_stream()
|
.bytes_stream()
|
||||||
.map_err(std::io::Error::other)
|
.map_err(std::io::Error::other)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue