Skip to content

Commit

Permalink
Remove unnecessary close when download file (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
yanghua authored Oct 24, 2024
1 parent 50b9c89 commit 9ac3614
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions tosfs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1017,20 +1017,8 @@ def download_file() -> None:
body, content_length = self._open_remote_file(
bucket, key, version_id, range_start=0, **kwargs
)
try:
with open(lpath, "wb") as f:
retryable_func_executor(_read_chunks, args=(body, f))
finally:
try:
body.close()
except Exception as e:
logger.error(
"Failed to close the body when calling "
"get_file from %s to %s: %s",
rpath,
lpath,
e,
)
with open(lpath, "wb") as f:
retryable_func_executor(_read_chunks, args=(body, f))

retryable_func_executor(download_file)

Expand Down

0 comments on commit 9ac3614

Please sign in to comment.