Skip to content

Use standard retry logic in _download_ranged #934

Description

@soxofaan

tries_left = MAX_RETRIES_PER_RANGE
while tries_left > 0:
try:
range_headers = {"Range": f"bytes={from_byte_index}-{to_byte_index}"}
with self.job.connection.get(path=url, headers=range_headers, stream=True) as r:
r.raise_for_status()
for block in r.iter_content(chunk_size=chunk_size):
f.write(block)
break
except OpenEoApiPlainError as error:
tries_left -= 1
if tries_left > 0 and error.http_status_code in RETRIABLE_STATUSCODES:
logger.warning(
f"Failed to retrieve chunk {from_byte_index}-{to_byte_index} from {url} (status {error.http_status_code}) - retrying"
)

as suggested in #933 (comment), replace this DIY retry logic with standard retry utilities like urllib3.util.Retry.

Actually, RestApiConnection already has such a retry config by default since #770 (for #441 and #764)
so the DIY retry logic can probably just be dropped

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions