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

Remove retry logic #2541

Merged
merged 1 commit into from
Mar 5, 2022
Merged
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
43 changes: 17 additions & 26 deletions custom_components/hacs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,36 +575,27 @@ async def async_download_file(self, url: str) -> bytes | None:
if url is None:
return None

tries_left = 5

if "tags/" in url:
url = url.replace("tags/", "")

self.log.debug("Downloading %s", url)

while tries_left > 0:
try:
request = await self.session.get(url=url, timeout=ClientTimeout(total=60))

# Make sure that we got a valid result
if request.status == 200:
return await request.read()

raise HacsException(
f"Got status code {request.status} when trying to download {url}"
)
except asyncio.TimeoutError:
self.log.error(
"A timeout of 60! seconds was encountered while downloading %s, "
"check the network on the host running Home Assistant",
url,
)
return None
except BaseException as exception: # lgtm [py/catch-base-exception] pylint: disable=broad-except
self.log.debug("Download failed - %s", exception)
tries_left -= 1
await asyncio.sleep(1)
continue
try:
request = await self.session.get(url=url, timeout=ClientTimeout(total=60))

# Make sure that we got a valid result
if request.status == 200:
return await request.read()

raise HacsException(f"Got status code {request.status} when trying to download {url}")
except asyncio.TimeoutError:
self.log.error(
"A timeout of 60! seconds was encountered while downloading %s, "
"check the network on the host running Home Assistant. This is "
"not a problem with HACS but how your host communicates with GitHub",
url,
)
except BaseException as exception: # lgtm [py/catch-base-exception] pylint: disable=broad-except
self.log.exception("Download failed - %s", exception)

self.log.error("Download from %s failed", url)
return None