Commit 001c282f authored by Tim Peters's avatar Tim Peters

_commitResources() and _cleanup(): When an exception occurs during

the former, remember it and raise it after calling _cleanup.  If
abort_sub() or tpc_abort() in _cleanup() also raise exceptions, log
them but don't propagate them.

This stops stray output produced by tests testExceptionInTpcAbort and
testExceptionInSubAbortSub.

Grrrrr:  I haven't yet been able to figure out how to get logging to work
in ZODB, so haven't yet been able to check that the new logging is
reasonable.
parent f1e323ce
...@@ -36,7 +36,7 @@ TODO ...@@ -36,7 +36,7 @@ TODO
add in tests for objects which are modified multiple times, add in tests for objects which are modified multiple times,
for example an object that gets modified in multiple sub txns. for example an object that gets modified in multiple sub txns.
$Id: testTransaction.py,v 1.22 2004/04/02 19:48:22 tim_one Exp $ $Id: testTransaction.py,v 1.23 2004/04/06 01:06:41 tim_one Exp $
""" """
import unittest import unittest
...@@ -385,9 +385,6 @@ class TransactionTests(unittest.TestCase): ...@@ -385,9 +385,6 @@ class TransactionTests(unittest.TestCase):
self.sub1.modify(nojar=1) self.sub1.modify(nojar=1)
try: try:
# XXX Transaction._cleanup() prints a stray "error tpc_abort"
# XXX (the string value of the TestTxnException instance raised)
# XXX to stdout.
get_transaction().commit() get_transaction().commit()
except TestTxnException: except TestTxnException:
pass pass
......
...@@ -305,6 +305,7 @@ class Transaction(object): ...@@ -305,6 +305,7 @@ class Transaction(object):
# to revert the changes in each of the resource managers. # to revert the changes in each of the resource managers.
# For top-level transactions, it must be freed from the # For top-level transactions, it must be freed from the
# txn manager. # txn manager.
t, v, tb = sys.exc_info()
try: try:
self._cleanup(L) self._cleanup(L)
finally: finally:
...@@ -312,7 +313,7 @@ class Transaction(object): ...@@ -312,7 +313,7 @@ class Transaction(object):
self.status = Status.FAILED self.status = Status.FAILED
if self._manager: if self._manager:
self._manager.free(self) self._manager.free(self)
raise raise t, v, tb
def _cleanup(self, L): def _cleanup(self, L):
# Called when an exception occurs during tpc_vote or tpc_finish. # Called when an exception occurs during tpc_vote or tpc_finish.
...@@ -323,15 +324,15 @@ class Transaction(object): ...@@ -323,15 +324,15 @@ class Transaction(object):
if id(rm) in self._sub: if id(rm) in self._sub:
try: try:
rm.abort_sub(self) rm.abort_sub(self)
except Exception, err: except Exception:
# XXX Just printing the error doesn't seem good enough. self.log.error("Error in abort_sub() on manager %s",
print err rm, exc_info=sys.exc_info())
else: else:
try: try:
rm.tpc_abort(self) rm.tpc_abort(self)
except Exception, err: except Exception:
# XXX Just printing the error doesn't seem good enough. self.log.error("Error in tpc_abort() on manager %s",
print err rm, exc_info=sys.exc_info())
def _getResourceManagers(self, subtransaction): def _getResourceManagers(self, subtransaction):
L = [] L = []
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment