Skip to content

Commit 6592fe2

Browse files
Copilotmbarbero
andauthored
chore: simplify repository-defaults retry loop readability
Agent-Logs-Url: https://github.com/eclipse-csi/otterdog/sessions/305839ba-b0c3-4931-b989-8b5354ec0cc8 Co-authored-by: mbarbero <452625+mbarbero@users.noreply.github.com>
1 parent 3bc41f2 commit 6592fe2

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

  • otterdog/providers/github

otterdog/providers/github/web.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -547,8 +547,10 @@ async def _goto(self, page: Page, url: str) -> None:
547547
Also, save a screenshot if trace logging is enabled.
548548
"""
549549
status = None
550-
max_attempts = self._REPO_DEFAULTS_404_RETRIES + 1
551-
for attempt in range(1, max_attempts + 1):
550+
max_retries = self._REPO_DEFAULTS_404_RETRIES
551+
max_attempts = max_retries + 1
552+
for retry_idx in range(max_retries + 1):
553+
attempt = retry_idx + 1
552554
_logger.trace("loading page '%s'", url)
553555
response = await page.goto(url)
554556
response = unwrap(response)
@@ -557,12 +559,12 @@ async def _goto(self, page: Page, url: str) -> None:
557559
if response.ok:
558560
break
559561

560-
if status == 404 and url.endswith(self._REPO_DEFAULTS_PAGE_URL) and attempt < max_attempts:
562+
if status == 404 and url.endswith(self._REPO_DEFAULTS_PAGE_URL) and retry_idx < max_retries:
561563
_logger.debug(
562564
"loading github page '%s' returned 404 (attempt %s/%s), retrying ...",
563565
url,
564566
attempt,
565-
self._REPO_DEFAULTS_404_RETRIES,
567+
max_attempts,
566568
)
567569
await sleep(self._REPO_DEFAULTS_404_RETRY_DELAY)
568570
continue

0 commit comments

Comments
 (0)