Skip to content

Commit

Permalink
[feat] Add tenacity retry for async paths with max retry of 5
Browse files Browse the repository at this point in the history
  • Loading branch information
kiritowu committed Nov 7, 2024
1 parent 1e84b83 commit 65b1173
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 12 deletions.
15 changes: 13 additions & 2 deletions nlb_catalogue_client/api/catalogue/get_get_availability_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
15 changes: 13 additions & 2 deletions nlb_catalogue_client/api/catalogue/get_get_new_titles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
15 changes: 13 additions & 2 deletions nlb_catalogue_client/api/catalogue/get_get_title_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
15 changes: 13 additions & 2 deletions nlb_catalogue_client/api/catalogue/get_get_titles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
15 changes: 13 additions & 2 deletions nlb_catalogue_client/api/catalogue/get_search_titles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 65b1173

Please sign in to comment.