in antlir/rpm/storage/storage.py [0:0]
def __exit__(self, exc_type, exc_val, exc_tb) -> bool:
# The end user never called `commit`, so they did not get an ID, and
# we should try to clean up.
if self.get_id_and_release_resources is not None:
assert self.id is None
assert self.remove
try:
# NB: If any of our storage implementation supported an
# explicit "abort" feature, we could plumb it through here,
# and tell the implementation to avoid committing altogether.
self(remove_on_exception=True)
self.remove = True
except BaseException: # pragma: no cover
# Mask the exception -- it came from our automatic attempt
# to release resources, so the end user should not care. By
# carrying on, we get to try to remove the ID if
# `get_id_and_release_resources` returned one, and then
# raised during its clean-up.
log.exception(
f"Error retrieving ID from {self.storage} while trying "
"to automatically clean up an uncommitted blob."
)
if exc_type:
# `self` must have been called, by the user, or just above.
if self.remove_on_exception:
assert self.get_id_and_release_resources is None
self.remove = True
if self.remove and self.id:
# pyre-fixme[16]: `Storage` has no attribute `remove`.
self.storage.remove(self.id)
return False # This context manager does not suppress exceptions