Commit 366cc906 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 77027e1a
......@@ -36,7 +36,7 @@ TODO
add in tests for objects which are modified multiple times,
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
......@@ -385,9 +385,6 @@ class TransactionTests(unittest.TestCase):
self.sub1.modify(nojar=1)
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()
except TestTxnException:
pass
......
......@@ -305,6 +305,7 @@ class Transaction(object):
# to revert the changes in each of the resource managers.
# For top-level transactions, it must be freed from the
# txn manager.
t, v, tb = sys.exc_info()
try:
self._cleanup(L)
finally:
......@@ -312,7 +313,7 @@ class Transaction(object):
self.status = Status.FAILED
if self._manager:
self._manager.free(self)
raise
raise t, v, tb
def _cleanup(self, L):
# Called when an exception occurs during tpc_vote or tpc_finish.
......@@ -323,15 +324,15 @@ class Transaction(object):
if id(rm) in self._sub:
try:
rm.abort_sub(self)
except Exception, err:
# XXX Just printing the error doesn't seem good enough.
print err
except Exception:
self.log.error("Error in abort_sub() on manager %s",
rm, exc_info=sys.exc_info())
else:
try:
rm.tpc_abort(self)
except Exception, err:
# XXX Just printing the error doesn't seem good enough.
print err
except Exception:
self.log.error("Error in tpc_abort() on manager %s",
rm, exc_info=sys.exc_info())
def _getResourceManagers(self, subtransaction):
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