kevinjqliu commented on code in PR #1246:
URL: https://github.com/apache/iceberg-python/pull/1246#discussion_r1817422310
##########
pyiceberg/table/__init__.py:
##########
@@ -231,9 +233,13 @@ def __enter__(self) -> Transaction:
"""Start a transaction to update the table."""
return self
- def __exit__(self, _: Any, value: Any, traceback: Any) -> None:
- """Close and commit the transaction."""
- self.commit_transaction()
+ def __exit__(
+ self, exctype: Optional[Type[BaseException]], excinst:
Optional[BaseException], exctb: Optional[TracebackType]
+ ) -> None:
+ """Close and commit the transaction, or handle exceptions."""
+ # Only commit the full transaction, if there is no exception in all
updates on the chain
+ if exctb is None:
Review Comment:
I'm a bit confused about this part. Typically `__exit__` is called as the
last step for the `with` statement.
Here, `__exit__` calls the `self.commit_transaction()` which will process
the transactions.
It seems like the issue here is to catch partial exceptions from the
`self.commit_transaction()` which wont be caught here
##########
pyiceberg/table/__init__.py:
##########
@@ -231,9 +233,13 @@ def __enter__(self) -> Transaction:
"""Start a transaction to update the table."""
return self
- def __exit__(self, _: Any, value: Any, traceback: Any) -> None:
- """Close and commit the transaction."""
- self.commit_transaction()
+ def __exit__(
+ self, exctype: Optional[Type[BaseException]], excinst:
Optional[BaseException], exctb: Optional[TracebackType]
+ ) -> None:
+ """Close and commit the transaction, or handle exceptions."""
+ # Only commit the full transaction, if there is no exception in all
updates on the chain
+ if exctb is None:
Review Comment:
what is the difference between `exctype`, `excinst`, and `exctb` here? Why
do we use `exctb`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]