in src/azstoragetorch/io.py [0:0]
def close(self) -> None:
"""Close the file-like object.
In write mode, this will :py:meth:`flush` and commit the blob.
:raises FatalBlobIOWriteError: if a fatal error occurs when writing to blob. If
raised, no data written, nor uploaded, using this :py:class:`BlobIO` instance will be
committed to the blob. It is recommended to create a new :py:class:`BlobIO`
instance and retry all writes when attempting retries.
"""
if self.closed:
return
try:
# Any errors that occur while flushing or committing the block list are considered non-recoverable
# when using the BlobIO interface. So if an error occurs, we still close the BlobIO to further indicate
# that a new BlobIO instance will be needed and also avoid possibly calling the flush/commit logic again
# during garbage collection.
if self.writable():
self._commit_blob()
finally:
self._close_client()
self._closed = True