Closed coler-j closed 2 years ago
If you're looking for something that you can independently rollback, but which (if not rolledback) still commits when the outer transaction commits, perhaps you want a savepoint:
tx = transaction.begin()
do_stuff()
savepoint = tx.savepoint()
try:
do_optional_stuff()
except Exception:
# Discard whatever the optional stuff did
savepoint.rollback()
# Commit whatever do_stuff() did, and if not rolled back, also
# the optional stuff
tx.commit()
What I did:
What would the following do:
What I expect to happen:
The inner transaction.manager would create a nested transaction under t1