File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed
Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change 11import json
2+ import logging
23from typing import Any , Callable
34
45import requests
89from nrlf .core .constants import Categories , PointerTypes
910from nrlf .core .model import ConnectionMetadata
1011
12+ logger = logging .getLogger (__name__ )
13+
1114
1215class ClientConfig (BaseModel ):
1316 base_url : str
@@ -44,18 +47,16 @@ def retry_if(status_codes: list[int]) -> Callable[..., Any]:
4447 def wrapped_func (func : Callable [..., Response ]) -> Callable [..., Response ]:
4548 def wrapper (* args : Any , ** kwargs : Any ) -> Any :
4649 attempt_responses : list [Response ] = []
47- for attempt in range (2 ):
50+ for attempt in range (3 ):
4851 response = func (* args , ** kwargs )
4952 if not response .status_code or response .status_code not in status_codes :
5053 return response
5154 attempt_responses .append (response )
52- print ( # noqa: T201
53- f"Retrying due to { response . status_code } error in attempt { attempt + 1 } ... "
55+ logger . warning (
56+ f"Attempt { attempt + 1 } failed with status code { response . status_code } "
5457 )
5558
56- print ( # noqa: T201
57- f"All attempts failed with responses: { attempt_responses } "
58- )
59+ logger .error (f"All attempts failed with responses: { attempt_responses } " )
5960 raise RuntimeError (
6061 f"Function failed after retries with responses: { attempt_responses } "
6162 )
You can’t perform that action at this time.
0 commit comments