Skip to content

Commit 5171475

Browse files
authored
chore: improve visz on 504: Error in partition - {"error": "Connection error while initiating partition request from unstructured_client", "message": "", "type": "partition_connection_error"} (#338)
504: Error in partition - {"error": "Connection error while initiating partition request from unstructured_client", "message": "", "type": "partition_connection_error"} change: "ReadError after 5 retries over 312.4s" instead of "message": "" <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Behavior only changes error formatting/raising when the backoff budget is exhausted; normal retry and success paths are unchanged. > > **Overview** > Improves observability when retries exceed `max_elapsed_time` by rethrowing the original exception type with a message that includes the number of attempts and total elapsed time (sync and async backoff paths), while preserving the original exception via chaining. > > Bumps the generated SDK version/user-agent from `0.43.2` to `0.43.3`. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 400e8e5. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 971a150 commit 5171475

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

src/unstructured_client/_version.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
import importlib.metadata
44

55
__title__: str = "unstructured-client"
6-
__version__: str = "0.43.2"
6+
__version__: str = "0.43.3"
77
__openapi_doc_version__: str = "1.2.31"
88
__gen_version__: str = "2.680.0"
9-
__user_agent__: str = "speakeasy-sdk/python 0.43.2 2.680.0 1.2.31 unstructured-client"
9+
__user_agent__: str = "speakeasy-sdk/python 0.43.3 2.680.0 1.2.31 unstructured-client"
1010

1111
try:
1212
if __package__ is not None:

src/unstructured_client/utils/retries.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,11 @@ def retry_with_backoff(
172172
if isinstance(exception, TemporaryError):
173173
return exception.response
174174

175-
raise
175+
elapsed_seconds = (now - start) / 1000
176+
raise type(exception)(
177+
f"{type(exception).__name__} after {retries + 1} attempts "
178+
f"over {elapsed_seconds:.1f}s: {exception}"
179+
) from exception
176180
sleep = (initial_interval / 1000) * exponent**retries + random.uniform(0, 1)
177181
sleep = min(sleep, max_interval / 1000)
178182
time.sleep(sleep)
@@ -200,7 +204,11 @@ async def retry_with_backoff_async(
200204
if isinstance(exception, TemporaryError):
201205
return exception.response
202206

203-
raise
207+
elapsed_seconds = (now - start) / 1000
208+
raise type(exception)(
209+
f"{type(exception).__name__} after {retries + 1} attempts "
210+
f"over {elapsed_seconds:.1f}s: {exception}"
211+
) from exception
204212
sleep = (initial_interval / 1000) * exponent**retries + random.uniform(0, 1)
205213
sleep = min(sleep, max_interval / 1000)
206214
await asyncio.sleep(sleep)

0 commit comments

Comments
 (0)