Skip to content

Commit

Permalink
Optimize: Introduce multiple disk write for MPU
Browse files Browse the repository at this point in the history
  • Loading branch information
yanghua committed Sep 20, 2024
1 parent b621bae commit 2230c6d
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions tosfs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2177,21 +2177,6 @@ def fetch() -> bytes:

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

def discard(self) -> None:
"""Close the file without writing."""
self._abort_mpu()
self.buffer = None # file becomes unusable

def _abort_mpu(self) -> None:
if self.mpu:
retryable_func_executor(
lambda: self.fs.tos_client.abort_multipart_upload(
self.bucket, self.key, self.mpu.upload_id
),
max_retry_num=self.fs.max_retry_num,
)
self.mpu = None

def commit(self) -> None:
"""Complete multipart upload or PUT."""
logger.debug("Commit %s", self)
Expand Down Expand Up @@ -2231,3 +2216,17 @@ def commit(self) -> None:

self.buffer = None

def discard(self) -> None:
"""Close the file without writing."""
self._abort_mpu()
self.buffer = None # file becomes unusable

def _abort_mpu(self) -> None:
if self.mpu:
retryable_func_executor(
lambda: self.fs.tos_client.abort_multipart_upload(
self.bucket, self.key, self.mpu.upload_id
),
max_retry_num=self.fs.max_retry_num,
)
self.mpu = None

0 comments on commit 2230c6d

Please sign in to comment.