Skip to content

Commit

Permalink
Merge pull request #158 from dinesh-aot/COMP-238
Browse files Browse the repository at this point in the history
retry mechanism for api calls to track
  • Loading branch information
dinesh-aot authored Dec 2, 2024
2 parents 41b4618 + c007399 commit ab4ed40
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
Binary file modified compliance-api/requirements.txt
Binary file not shown.
3 changes: 2 additions & 1 deletion compliance-api/requirements/prod.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ requests
flask_cors
pyhumps
importlib-resources
pycryptodome==3.20.0
pycryptodome==3.20.0
tenacity==9.0.0
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import requests
from flask import current_app, g
from tenacity import retry, retry_if_exception_type, stop_after_attempt, wait_fixed

from compliance_api.exceptions import BusinessError
from compliance_api.utils.enum import HttpMethod
Expand Down Expand Up @@ -45,6 +46,11 @@ def get_first_nation_by_id(first_nation_id: int):
return first_nation_response.json()


@retry(
retry=retry_if_exception_type(requests.exceptions.RequestException),
stop=stop_after_attempt(3), # Retry up to 3 times
wait=wait_fixed(2), # Wait 2 seconds between retries
)
def _request_track_service(
relative_url, http_method: HttpMethod = HttpMethod.GET, data=None
):
Expand Down

0 comments on commit ab4ed40

Please sign in to comment.