From a4aeee20d9166f6b3f4684a568cc5811272bcc14 Mon Sep 17 00:00:00 2001 From: "John T. Wodder II" Date: Wed, 2 Nov 2022 14:37:42 -0400 Subject: [PATCH] Revert "Merge pull request #151 from con/gh-150" This reverts commit ac3116caef27035c6af9f0d95e1237e8e68f7824, reversing changes made to 655bb1c8326399b760d06a3aa8a409db4cac7d00. --- src/tinuous/github.py | 49 +++++++------------------------------------ 1 file changed, 7 insertions(+), 42 deletions(-) diff --git a/src/tinuous/github.py b/src/tinuous/github.py index c832988..4b4b66a 100644 --- a/src/tinuous/github.py +++ b/src/tinuous/github.py @@ -7,13 +7,12 @@ from github import Github from github.GitRelease import GitRelease from github.GitReleaseAsset import GitReleaseAsset -from github.GithubException import RateLimitExceededException, UnknownObjectException +from github.GithubException import RateLimitExceededException from github.Repository import Repository from github.Workflow import Workflow from github.WorkflowRun import WorkflowRun from pydantic import BaseModel, Field import requests -from urllib3.exceptions import ResponseError from urllib3.util.retry import Retry from .base import ( @@ -35,12 +34,6 @@ sanitize_pathname, ) -RETRY_STATUSES = [500, 502, 503, 504] - -RETRY_RESPONSE_ERRORS = { - ResponseError.SPECIFIC_ERROR.format(status_code=c): c for c in RETRY_STATUSES -} - def retry_ratelimit(func: Callable) -> Callable: @wraps(func) @@ -73,7 +66,7 @@ def client(self) -> Github: retry=Retry( total=12, backoff_factor=1.25, - status_forcelist=RETRY_STATUSES, + status_forcelist=[500, 502, 503, 504], ), ) @@ -105,39 +98,11 @@ def get_workflows(self) -> List[Workflow]: @retry_ratelimit def get_runs(self, wf: Workflow, since: datetime) -> List[WorkflowRun]: runs: List[WorkflowRun] = [] - try: - for r in wf.get_runs(): - if ensure_aware(r.created_at) <= since: - break - runs.append(r) - return runs - except requests.exceptions.RetryError as e: - reason = e.args[0].reason - if ( - isinstance(reason, ResponseError) - and reason.args[0] in RETRY_RESPONSE_ERRORS - and ensure_aware(wf.updated_at) <= since - and not (wf.path and self.has_file(wf.path)) - ): - log.warning( - "Request for runs for workflow %s (%s) returned %d, and" - " workflow was deleted before starting timestamp; skipping", - wf.path, - wf.name, - RETRY_RESPONSE_ERRORS[reason.args[0]], - ) - return [] - else: - raise - - @retry_ratelimit - def has_file(self, path: str) -> bool: - try: - self.ghrepo.get_contents(path) - except UnknownObjectException: - return False - else: - return True + for r in wf.get_runs(): + if ensure_aware(r.created_at) <= since: + break + runs.append(r) + return runs def get_build_assets( self, event_types: List[EventType], logs: bool, artifacts: bool