mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 04:02:00 -06:00
Add retry if connection got reset by peer (#144)
This commit is contained in:
parent
3c648f4192
commit
95f8cc542c
1 changed files with 13 additions and 3 deletions
|
|
@ -529,11 +529,21 @@ pub async fn download_segments(
|
|||
for (i, segment) in thread_segments.into_iter().enumerate() {
|
||||
let mut retry_count = 0;
|
||||
let mut buf = loop {
|
||||
let response = thread_client
|
||||
let request = thread_client
|
||||
.get(&segment.url)
|
||||
.timeout(Duration::from_secs(60))
|
||||
.send()
|
||||
.await?;
|
||||
.send();
|
||||
|
||||
let response = match request.await {
|
||||
Ok(r) => r,
|
||||
Err(e) => {
|
||||
if retry_count == 5 {
|
||||
bail!("Max retry count reached ({}), multiple errors occurred while receiving segment {}: {}", retry_count, num + (i * cpus), e)
|
||||
}
|
||||
debug!("Failed to download segment {} ({}). Retrying, {} out of 5 retries left", num + (i * cpus), e, 5 - retry_count);
|
||||
continue
|
||||
}
|
||||
};
|
||||
|
||||
match response.bytes().await {
|
||||
Ok(b) => break b.to_vec(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue