Skip to content

Commit a7f5477

Browse files
committed
edit log message
1 parent 413cd81 commit a7f5477

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/unstructured_client/utils/_human_utils.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,16 @@ def wrapper(*args: _P.args, **kwargs: _P.kwargs) -> operations.PartitionResponse
9393
return wrapper
9494

9595

96-
def log_retries(retry_count: int, sleep: float):
96+
def log_retries(retry_count: int, sleep: float, exception: Exception):
9797
"""Function for logging retries to give users visibility into requests."""
9898
logging.basicConfig(level=logging.INFO, format='%(levelname)s: %(message)s', stream=sys.stdout)
9999
logger = logging.getLogger('unstructured-client')
100100
logger.setLevel(logging.INFO)
101101
logger.info(
102-
"Retry attempt #%s. Sleeping %s seconds before retry.", retry_count, round(sleep, 1)
102+
"Response status code: %s Retry attempt #%s. Sleeping %s seconds before retry.",
103+
exception.response.status_code,
104+
retry_count,
105+
round(sleep, 1),
103106
)
107+
if bool(exception.response.text):
108+
logger.info(exception.response.text)

src/unstructured_client/utils/retries.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,6 @@ def retry_with_backoff(func, initial_interval=500, max_interval=60000, exponent=
118118
exponent**retries + random.uniform(0, 1))
119119
if sleep > max_interval/1000:
120120
sleep = max_interval/1000
121-
log_retries(retry_count=retries+1, sleep=sleep) # human code
121+
log_retries(retry_count=retries+1, sleep=sleep, exception=exception) # human code
122122
time.sleep(sleep)
123123
retries += 1

0 commit comments

Comments
 (0)