From 3c988a7590f545a126236ac364a243efc9dc687b Mon Sep 17 00:00:00 2001 From: Maja Massarini Date: Tue, 1 Oct 2024 15:56:17 +0200 Subject: [PATCH] On github errors, retry once, and return a result or an exception This commit is meant to fix point 5. on analysis at https://gist.github.com/majamassarini/85033b59607a3f3da570cf5aaf2b8c7a raise_on_status (in urllib3.Retry) meaning is: Similar meaning to raise_on_redirect: whether we should raise an exception, or return a response, if status falls in status_forcelist range and retries have been exhausted. I would force to have or a result or an exception for not making Celery task hanging. --- ogr/services/github/service.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ogr/services/github/service.py b/ogr/services/github/service.py index b4452294..76d20a04 100644 --- a/ogr/services/github/service.py +++ b/ogr/services/github/service.py @@ -49,7 +49,7 @@ def __init__( github_app_private_key_path: Optional[str] = None, tokman_instance_url: Optional[str] = None, github_authentication: GithubAuthentication = None, - max_retries: Union[int, Retry] = 0, + max_retries: Union[int, Retry] = 1, **kwargs, ): """ @@ -69,12 +69,11 @@ def __init__( else: self._max_retries = Retry( total=int(max_retries), - read=0, # Retry mechanism active for these HTTP methods: allowed_methods=["DELETE", "GET", "PATCH", "POST", "PUT"], # Only retry on following HTTP status codes status_forcelist=[500, 503, 403, 401], - raise_on_status=False, + raise_on_status=True, ) if not self._default_auth_method: