Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retry failed HTTP(S) fetches when appropriate. #118

Merged
merged 1 commit into from
Jan 6, 2025

Conversation

jsirois
Copy link
Contributor

@jsirois jsirois commented Jan 5, 2025

Fixes #116

@jsirois
Copy link
Contributor Author

jsirois commented Jan 5, 2025

@achimnol if you could take a look, I'd appreciate it.

reraise=True,
retry=retry_if_exception(
lambda ex: (
isinstance(ex, TimeoutException)
Copy link
Contributor Author

@jsirois jsirois Jan 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

N.B.: I tested most of this config by using a temporary low timeout on the httpx.Client. You do get 2 warning logs before the 2 retries and the final exception is the timeout of the last try.

@@ -99,6 +135,7 @@ def _fetch_to_cache(
configured_client(url, headers).stream("GET", url) as response,
work.open("wb") as cache_fp,
):
response.raise_for_status()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This missing response.raise_for_status and the one added below were likely bugs that may combine with the rest of this code to actually fix the OP issue. Discussion here: #116 (comment)

Even if not, I'd like to proceed with the change since retries seem like a good idea to me independently of #116.

Copy link
Collaborator

@huonw huonw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. The fail-open API of requiring an explicit raise_for_status on each response is definitely annoying/makes it easy to miss!

@jsirois jsirois merged commit 87a4c53 into a-scie:main Jan 6, 2025
10 checks passed
@jsirois jsirois deleted the issues/116 branch January 6, 2025 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Intermittent failure with missing release_data["name"] when loading PBS
2 participants