From 65b1173d271bd05fc8fc6c73505b5bd89dcc4297 Mon Sep 17 00:00:00 2001 From: kiritowu Date: Thu, 7 Nov 2024 14:59:44 +0800 Subject: [PATCH] [feat] Add tenacity retry for async paths with max retry of 5 --- .../api/catalogue/get_get_availability_info.py | 15 +++++++++++++-- .../get_get_most_checkouts_trends_titles.py | 15 +++++++++++++-- .../api/catalogue/get_get_new_titles.py | 15 +++++++++++++-- .../api/catalogue/get_get_title_details.py | 15 +++++++++++++-- .../api/catalogue/get_get_titles.py | 15 +++++++++++++-- .../api/catalogue/get_search_titles.py | 15 +++++++++++++-- 6 files changed, 78 insertions(+), 12 deletions(-) diff --git a/nlb_catalogue_client/api/catalogue/get_get_availability_info.py b/nlb_catalogue_client/api/catalogue/get_get_availability_info.py index 2d29c7f..cd6cc18 100644 --- a/nlb_catalogue_client/api/catalogue/get_get_availability_info.py +++ b/nlb_catalogue_client/api/catalogue/get_get_availability_info.py @@ -2,7 +2,7 @@ from typing import Any, Dict, Optional, Union import httpx -from tenacity import retry, retry_if_result, wait_exponential +from tenacity import retry, retry_if_result, stop_after_attempt, wait_exponential from ... import errors from ...client import AuthenticatedClient, Client @@ -125,7 +125,12 @@ def _build_response( ) -@retry(retry=retry_if_result(lambda x: x.status_code == 429), wait=wait_exponential()) +@retry( + retry=retry_if_result(lambda x: x.status_code == 429), + wait=wait_exponential(), + stop=stop_after_attempt(5), + retry_error_callback=lambda x: x.outcome.result() if x.outcome else None, +) def sync_detailed( *, client: AuthenticatedClient, @@ -245,6 +250,12 @@ def sync( ).parsed +@retry( + retry=retry_if_result(lambda x: x.status_code == 429), + wait=wait_exponential(), + stop=stop_after_attempt(5), + retry_error_callback=lambda x: x.outcome.result() if x.outcome else None, +) async def asyncio_detailed( *, client: AuthenticatedClient, diff --git a/nlb_catalogue_client/api/catalogue/get_get_most_checkouts_trends_titles.py b/nlb_catalogue_client/api/catalogue/get_get_most_checkouts_trends_titles.py index 52346e3..3aa1358 100644 --- a/nlb_catalogue_client/api/catalogue/get_get_most_checkouts_trends_titles.py +++ b/nlb_catalogue_client/api/catalogue/get_get_most_checkouts_trends_titles.py @@ -2,7 +2,7 @@ from typing import Any, Dict, Optional, Union import httpx -from tenacity import retry, retry_if_result, wait_exponential +from tenacity import retry, retry_if_result, stop_after_attempt, wait_exponential from ... import errors from ...client import AuthenticatedClient, Client @@ -113,7 +113,12 @@ def _build_response( ) -@retry(retry=retry_if_result(lambda x: x.status_code == 429), wait=wait_exponential()) +@retry( + retry=retry_if_result(lambda x: x.status_code == 429), + wait=wait_exponential(), + stop=stop_after_attempt(5), + retry_error_callback=lambda x: x.outcome.result() if x.outcome else None, +) def sync_detailed( *, client: AuthenticatedClient, @@ -201,6 +206,12 @@ def sync( ).parsed +@retry( + retry=retry_if_result(lambda x: x.status_code == 429), + wait=wait_exponential(), + stop=stop_after_attempt(5), + retry_error_callback=lambda x: x.outcome.result() if x.outcome else None, +) async def asyncio_detailed( *, client: AuthenticatedClient, diff --git a/nlb_catalogue_client/api/catalogue/get_get_new_titles.py b/nlb_catalogue_client/api/catalogue/get_get_new_titles.py index 1ac17ff..0c0e34c 100644 --- a/nlb_catalogue_client/api/catalogue/get_get_new_titles.py +++ b/nlb_catalogue_client/api/catalogue/get_get_new_titles.py @@ -2,7 +2,7 @@ from typing import Any, Dict, List, Optional, Union import httpx -from tenacity import retry, retry_if_result, wait_exponential +from tenacity import retry, retry_if_result, stop_after_attempt, wait_exponential from ... import errors from ...client import AuthenticatedClient, Client @@ -162,7 +162,12 @@ def _build_response( ) -@retry(retry=retry_if_result(lambda x: x.status_code == 429), wait=wait_exponential()) +@retry( + retry=retry_if_result(lambda x: x.status_code == 429), + wait=wait_exponential(), + stop=stop_after_attempt(5), + retry_error_callback=lambda x: x.outcome.result() if x.outcome else None, +) def sync_detailed( *, client: AuthenticatedClient, @@ -314,6 +319,12 @@ def sync( ).parsed +@retry( + retry=retry_if_result(lambda x: x.status_code == 429), + wait=wait_exponential(), + stop=stop_after_attempt(5), + retry_error_callback=lambda x: x.outcome.result() if x.outcome else None, +) async def asyncio_detailed( *, client: AuthenticatedClient, diff --git a/nlb_catalogue_client/api/catalogue/get_get_title_details.py b/nlb_catalogue_client/api/catalogue/get_get_title_details.py index 89593e6..4b96d75 100644 --- a/nlb_catalogue_client/api/catalogue/get_get_title_details.py +++ b/nlb_catalogue_client/api/catalogue/get_get_title_details.py @@ -2,7 +2,7 @@ from typing import Any, Dict, Optional, Union import httpx -from tenacity import retry, retry_if_result, wait_exponential +from tenacity import retry, retry_if_result, stop_after_attempt, wait_exponential from ... import errors from ...client import AuthenticatedClient, Client @@ -113,7 +113,12 @@ def _build_response( ) -@retry(retry=retry_if_result(lambda x: x.status_code == 429), wait=wait_exponential()) +@retry( + retry=retry_if_result(lambda x: x.status_code == 429), + wait=wait_exponential(), + stop=stop_after_attempt(5), + retry_error_callback=lambda x: x.outcome.result() if x.outcome else None, +) def sync_detailed( *, client: AuthenticatedClient, @@ -209,6 +214,12 @@ def sync( ).parsed +@retry( + retry=retry_if_result(lambda x: x.status_code == 429), + wait=wait_exponential(), + stop=stop_after_attempt(5), + retry_error_callback=lambda x: x.outcome.result() if x.outcome else None, +) async def asyncio_detailed( *, client: AuthenticatedClient, diff --git a/nlb_catalogue_client/api/catalogue/get_get_titles.py b/nlb_catalogue_client/api/catalogue/get_get_titles.py index f752a1b..5a439fa 100644 --- a/nlb_catalogue_client/api/catalogue/get_get_titles.py +++ b/nlb_catalogue_client/api/catalogue/get_get_titles.py @@ -2,7 +2,7 @@ from typing import Any, Dict, Optional, Union import httpx -from tenacity import retry, wait_exponential, retry_if_result +from tenacity import retry, retry_if_result, stop_after_attempt, wait_exponential from ... import errors from ...client import AuthenticatedClient, Client @@ -134,7 +134,12 @@ def _build_response( ) -@retry(retry=retry_if_result(lambda x: x.status_code == 429), wait=wait_exponential()) +@retry( + retry=retry_if_result(lambda x: x.status_code == 429), + wait=wait_exponential(), + stop=stop_after_attempt(5), + retry_error_callback=lambda x: x.outcome.result() if x.outcome else None, +) def sync_detailed( *, client: AuthenticatedClient, @@ -268,6 +273,12 @@ def sync( ).parsed +@retry( + retry=retry_if_result(lambda x: x.status_code == 429), + wait=wait_exponential(), + stop=stop_after_attempt(5), + retry_error_callback=lambda x: x.outcome.result() if x.outcome else None, +) async def asyncio_detailed( *, client: AuthenticatedClient, diff --git a/nlb_catalogue_client/api/catalogue/get_search_titles.py b/nlb_catalogue_client/api/catalogue/get_search_titles.py index 4d18bd1..a1fe76b 100644 --- a/nlb_catalogue_client/api/catalogue/get_search_titles.py +++ b/nlb_catalogue_client/api/catalogue/get_search_titles.py @@ -2,7 +2,7 @@ from typing import Any, Dict, List, Optional, Union import httpx -from tenacity import retry, retry_if_result, wait_exponential +from tenacity import retry, retry_if_result, stop_after_attempt, wait_exponential from ... import errors from ...client import AuthenticatedClient, Client @@ -169,7 +169,12 @@ def _build_response( ) -@retry(retry=retry_if_result(lambda x: x.status_code == 429), wait=wait_exponential()) +@retry( + retry=retry_if_result(lambda x: x.status_code == 429), + wait=wait_exponential(), + stop=stop_after_attempt(5), + retry_error_callback=lambda x: x.outcome.result() if x.outcome else None, +) def sync_detailed( *, client: AuthenticatedClient, @@ -323,6 +328,12 @@ def sync( ).parsed +@retry( + retry=retry_if_result(lambda x: x.status_code == 429), + wait=wait_exponential(), + stop=stop_after_attempt(5), + retry_error_callback=lambda x: x.outcome.result() if x.outcome else None, +) async def asyncio_detailed( *, client: AuthenticatedClient,