[Zodb-checkins]
SVN: ZODB/branches/anguenot-after_commit_hooks/src/transaction/_transaction.py
catch abort exceptions and log. XXX should we do some more in
this case to ensure the transaction will not be messed up ?
Julien Anguenot
ja at nuxeo.com
Tue Dec 20 20:47:22 EST 2005
Log message for revision 40934:
catch abort exceptions and log. XXX should we do some more in this case to ensure the transaction will not be messed up ?
Changed:
U ZODB/branches/anguenot-after_commit_hooks/src/transaction/_transaction.py
-=-
Modified: ZODB/branches/anguenot-after_commit_hooks/src/transaction/_transaction.py
===================================================================
--- ZODB/branches/anguenot-after_commit_hooks/src/transaction/_transaction.py 2005-12-21 01:31:29 UTC (rev 40933)
+++ ZODB/branches/anguenot-after_commit_hooks/src/transaction/_transaction.py 2005-12-21 01:47:22 UTC (rev 40934)
@@ -405,7 +405,7 @@
# XXX should we catch the exceptions ?
self._callAfterCommitHooks(status=True)
self.log.debug("commit")
-
+
def _saveAndGetCommitishError(self):
self.status = Status.COMMITFAILED
# Save the traceback for TransactionFailedError.
@@ -455,12 +455,13 @@
self._after_commit.append((hook, tuple(args), kws))
def _callAfterCommitHooks(self, status=True):
+ # Avoid to abort anything at the end if no hooks are registred.
+ if not self._after_commit:
+ return
# Call all hooks registered, allowing further registrations
# during processing. Note that calls to addAterCommitHook() may
# add additional hooks while hooks are running, and iterating over a
# growing list is well-defined in Python.
- if not self._after_commit:
- return
for hook, args, kws in self._after_commit:
# The first argument passed to the hook is a Boolean value,
# true if the commit succeeded, or false if the commit aborted.
@@ -472,14 +473,18 @@
# to be called
self.log.error("Error in after commit hook exec in %s ",
hook, exc_info=sys.exc_info())
- self._after_commit = []
# The transaction is already committed. It must not have
# further effects after the commit.
for rm in self._resources:
- # XXX is it ok for every ressource managers ?
- rm.abort(self)
+ try:
+ rm.abort(self)
+ except Exception:
+ # XXX should we take further actions here ?
+ self.log.error("Error in abort() on manager %s",
+ rm, exc_info=sys.exc_info())
+ self._after_commit = []
self._before_commit = []
-
+
def _commitResources(self):
# Execute the two-phase commit protocol.
More information about the Zodb-checkins
mailing list