From 732d935e9462ea97b3b92723005a6a16bd59ba87 Mon Sep 17 00:00:00 2001 From: vinoyang Date: Tue, 26 Nov 2024 19:37:09 +0800 Subject: [PATCH] Remove try-catch in fetch method let retry work (#313) --- tosfs/core.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/tosfs/core.py b/tosfs/core.py index e0a460b..c375226 100644 --- a/tosfs/core.py +++ b/tosfs/core.py @@ -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)