Skip to content

Commit

Permalink
Catch exceptions in fetch method to enhance stability
Browse files Browse the repository at this point in the history
  • Loading branch information
yanghua committed Sep 24, 2024
1 parent 00a83b3 commit 25c04f7
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions tosfs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2107,15 +2107,18 @@ def _fetch_range(self, start: int, end: int) -> bytes:

def fetch() -> bytes:
with io.BytesIO() as temp_buffer:
for chunk in self.fs.tos_client.get_object(
self.bucket,
self.key,
self.version_id,
range_start=start,
range_end=end,
):
temp_buffer.write(chunk)
return temp_buffer.getvalue()
try:
for chunk in self.fs.tos_client.get_object(
self.bucket,
self.key,
self.version_id,
range_start=start,
range_end=end,
):
temp_buffer.write(chunk)
return temp_buffer.getvalue()
except Exception as e:
raise TosClientError(f"{e}", e) from e

return retryable_func_executor(fetch, max_retry_num=self.fs.max_retry_num)

Expand Down

0 comments on commit 25c04f7

Please sign in to comment.