Add retries to tests that download from R2 (#15322)
Closes https://github.com/astral-sh/uv/issues/15318.
This commit is contained in:
Generated
+1
@@ -4994,6 +4994,7 @@ dependencies = [
|
||||
"assert_cmd",
|
||||
"assert_fs",
|
||||
"axoupdater",
|
||||
"backon",
|
||||
"base64 0.22.1",
|
||||
"byteorder",
|
||||
"clap",
|
||||
|
||||
@@ -117,6 +117,7 @@ windows-result = { workspace = true }
|
||||
[dev-dependencies]
|
||||
assert_cmd = { workspace = true }
|
||||
assert_fs = { workspace = true }
|
||||
backon = { workspace = true }
|
||||
base64 = { workspace = true }
|
||||
byteorder = { workspace = true }
|
||||
filetime = { workspace = true }
|
||||
|
||||
@@ -1,10 +1,22 @@
|
||||
#![cfg(feature = "r2")]
|
||||
|
||||
use backon::{BackoffBuilder, Retryable};
|
||||
use futures::TryStreamExt;
|
||||
use tokio_util::compat::FuturesAsyncReadCompatExt;
|
||||
|
||||
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
|
||||
.bytes_stream()
|
||||
.map_err(std::io::Error::other)
|
||||
|
||||
Reference in New Issue
Block a user