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

Add retry loop around http request #1024

Merged
merged 5 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/rocm_docs/rocm_docs_theme/flavors/rocm/header.jinja
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{% macro top_level_header(branch, latest_version, release_candidate_version) -%}
{% if branch in ["develop", "master", "main", "amd-master", "amd-staging"] %}
{% set version_name = "Future Release" %}
{% elif release_candidate_version in branch %}
{% set version_name = release_candidate_version %}
{% elif branch == "latest" %}
{% set version_name = latest_version %}
{% else %}
Expand Down
10 changes: 10 additions & 0 deletions src/rocm_docs/theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from typing import Any

import time
from pathlib import Path

import requests
Expand All @@ -16,10 +17,19 @@

logger = sphinx.util.logging.getLogger(__name__)

MAX_RETRY = 20


def _get_version_from_url(url: str) -> str:
try:
retry_counter = 0
response = requests.get(url)

# Retry in case of failure
while (response.status_code != 200) and (retry_counter <= MAX_RETRY):
time.sleep(5)
response = requests.get(url)

return response.text.strip()
except requests.RequestException as e:
print(f"Error in rocm-docs-core _get_version_from_url: {e}")
Expand Down
Loading