Skip to content

Commit

Permalink
Remove try-catch in fetch method let retry work
Browse files Browse the repository at this point in the history
  • Loading branch information
yanghua committed Nov 26, 2024
1 parent 70d5157 commit e66adf4
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions tosfs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2437,18 +2437,15 @@ def _fetch_range(self, start: int, end: int) -> bytes:

def fetch() -> bytes:
with io.BytesIO() as temp_buffer:
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
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()

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

Expand Down

0 comments on commit e66adf4

Please sign in to comment.