Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/transaction/_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,16 @@ class Status(object):
COMMITTING = "Committing"
COMMITTED = "Committed"

ABORTING = "Aborting"
ABORTED = "Aborted"

DOOMED = "Doomed"

# commit() or commit(True) raised an exception. All further attempts
# to commit or join this transaction will raise TransactionFailedError.
# commit() or commit(True) or abort() raised an exception. All further
# attempts to commit or join this transaction will raise
# TransactionFailedError.
COMMITFAILED = "Commit failed"
ABORTFAILED = "Abort failed"


class _NoSynchronizers(object):
Expand Down Expand Up @@ -542,6 +547,7 @@ def abort(self):

try:
self._synchronizers.map(lambda s: s.beforeCompletion(self))
self.status = Status.ABORTING
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably move that down to line 555, right before the for rm in self._resources loop which iterates and aborts.

except: # noqa: E722 do not use bare 'except'
t, v, tb = sys.exc_info()
self.log.error(
Expand All @@ -551,10 +557,13 @@ def abort(self):
try:
rm.abort(self)
except: # noqa: E722 do not use bare 'except'
self.status = Status.ABORTFAILED
if tb is None:
t, v, tb = sys.exc_info()
self.log.error("Failed to abort resource manager: %s",
rm, exc_info=sys.exc_info())
if self.status != Status.ABORTFAILED:
self.status = Status.ABORTED

self._callAfterAbortHooks()
# Unlike in commit(), we are no longer the current transaction
Expand Down
2 changes: 1 addition & 1 deletion src/transaction/tests/test__transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ def free(self, txn):
logger._clear()
mgr = txn._manager = _Mgr(txn)
txn.abort()
self.assertEqual(txn.status, Status.ACTIVE)
self.assertEqual(txn.status, Status.ABORTED)
self.assertTrue(mgr._txn is None)
self.assertEqual(logger._log[0][0], 'debug')
self.assertEqual(logger._log[0][1], 'abort')
Expand Down