MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _do_commit

Method _do_commit

lib/sqlalchemy/engine/base.py:2709–2735  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2707 self._close_impl(try_deactivate=True)
2708
2709 def _do_commit(self) -> None:
2710 if self.is_active:
2711 assert self.connection._transaction is self
2712
2713 try:
2714 self._connection_commit_impl()
2715 finally:
2716 # whether or not commit succeeds, cancel any
2717 # nested transactions, make this transaction "inactive"
2718 # and remove it as a reset agent
2719 if self.connection._nested_transaction:
2720 self.connection._nested_transaction._cancel()
2721
2722 self._deactivate_from_connection()
2723
2724 # ...however only remove as the connection's current transaction
2725 # if commit succeeded. otherwise it stays on so that a rollback
2726 # needs to occur.
2727 self.connection._transaction = None
2728 else:
2729 if self.connection._transaction is self:
2730 self.connection._invalid_transaction()
2731 else:
2732 raise exc.InvalidRequestError("This transaction is inactive")
2733
2734 assert not self.is_active
2735 assert self.connection._transaction is not self
2736
2737
2738class NestedTransaction(Transaction):

Callers

nothing calls this directly

Calls 4

_cancelMethod · 0.80
_invalid_transactionMethod · 0.80

Tested by

no test coverage detected