Skip to content

Commit

Permalink
Merge pull request #1024 from ROCm/amd/alexxu12/headerFix
Browse files Browse the repository at this point in the history
fix: Add retry loop around http request
  • Loading branch information
alexxu-amd authored Nov 15, 2024
2 parents 3cc8b6c + f0a51b2 commit 461694b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
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

0 comments on commit 461694b

Please sign in to comment.